views:

111

answers:

1

Hello, I need to define a new constant in Visual Studio.

I explain: I have a custom Compile Configuration (sorry I'm not sure the name is exact, I have a localized version of VS), and I need to define another constant besides the TRACE and DEBUG ones.

How can I do it?

+1  A: 

You can do it in two ways:

  • in the top of one of your code files, write the line:

    #define MYCONSTANT

then elsewhere within the same file you can refer to it with code like

#ifdef MYCONSTANT
    ... some code...
#endif
  • right click on a project file, select Properties. In the Build tab, you have a checkbox for each of the two constants you mentioned - above that is a textbox, enter your new constant there. You don't assign it a value, just the fact that it is declared is all you need.
slugster
Sorry for the dumb question, I found it.I was expecting "Custom defined constants" or something like that instead of the label of THAT textbox