C# – Solution-wide #define

cc-preprocessor

Is there a way to globally declare a #define?

Like I want to have a file that has for instance,

#define MONO

and I want all source-code files to know that this pre-processor directive is defined. How would I achieve that?

Best Answer

Update: You cannot do a "solution-wide" define afaik, however the answer below is workable on a per-project basis.

You set them in your Compilation Properties or Build options:

http://msdn.microsoft.com/en-US/library/76zdzba1(v=VS.80).aspx (VS2008) http://msdn.microsoft.com/en-US/library/76zdzba1(v=VS.100).aspx (VS2010)

see the "To set a custom constant" heading.

Update

Microsoft Documentation on Build Options

You get to the build options by right-clicking the project and selecting properties from the menu.

Project Build Options