#115 – Using #if, #else, #endif

When using the #if directive to conditionally compile code if a particular symbol is defined, you can also  using #else to conditionally compile code if the symbol is not defined.

Here’s an example:

#if LOGGING
    DoLotsOfLogging();   // To assist in debugging
#else
    DoMinimalLogging();
#endif

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

Leave a comment