I know that I can use preprocessor directives in C# to enable / disable compilation of some part of the code.
If I define a directive in the same file, it works fine:
#define LINQ_ENABLED using System; using System.Collections.Generic; #if LINQ_ENABLED using System.Linq; #endif
Now I use C++ to put all these configuration directives inside one header file and include it in all files where I need such directives.
If I do the same in C# , something doesn't work:
//Config.cs
I also tried the following, but it seems that I cannot define the directive inside the namespace:
//Config.cs namespace Conf{
- What am I doing wrong?
- What is the correct way to use a preprocessor for different files in
C# ? - Is there a better way to do this?
c # c-preprocessor conditional-compilation
Heisenbug
source share