#492 – Define Your Own Conditional Compilation Symbol

You can define your own conditional compilation symbols for specific build configurations and then use the #if directive to check these symbols and conditionally compile code, depending on whether the symbol is defined or not.

For example, suppose you want to execute some debugging code only for Debug builds that are targeting the x86 platform.  You can define a new DEBUG86 symbol that is present only when the build configuration is Debug and the platform is x86.

You can then use the #if directive to compile some code only when this symbol is defined.

#if DEBUG86
            Console.WriteLine("This is a 32-bit Debug build..");

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: