开发者

How can I define in Visual Studio a new constant?

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?


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜