Trying to define a preprocessor directives in the Visual studio 2012.
#define FLAG
....
#endif
But not sure, where to include this FLAG
in visual studio - C#. I remember specifying something like this in C++ projects.
Any thoughts ?
Trying to define a preprocessor directives in the Visual studio 2012.
#define FLAG
....
#endif
But not sure, where to include this FLAG
in visual studio - C#. I remember specifying something like this in C++ projects.
Any thoughts ?
You have two options as to where to define it:
Code file level - In the beginning of the file write #define FLAG
. You cannot place anything else (other than comments and blank lines) before define
directives. As Ron Beyer points out, a directive defined in a file exists only for that file.
Project level - Right click in the project in Solution Explorer, select Properties
, then the Build
tab, then look at Conditional compilation symbols
. Then one can define several comma-separated symbols there such as: FLAG,FOO,BAR
. Note that this symbols list is project configuration dependent (there is a configuration selector in the same tab).
Note as mentioned in the comments, define
does not work in C# the same way that it does in C. In C# you just declare that the symbol exists, but you can't assign a value to it. Hence the only use for these symbols is for #if FLAG
directives and for the Conditional attribute.
For some reason, when properties clicked, nothing happened for me. So I did the following. And it worked.
Open your csproj project file using text editor and add your preprocessor compiler directives in between these. <DefineConstants> HERE!!! </DefineConstants>