Is it really necessary to explicitly define "undefine" even when the define is commented out?

122 Views Asked by At

I was having some problems with this code executing:

#if TRACE
            dbgLog = new LogInfo( "PlatypusCE" );
#endif   

This was occurring even though "TRACE" was commented out above, right after a large block of general comments:

//#define TRACE

Once I added this below it:

#undef TRACE

...so that it is:

//#define TRACE
#undef TRACE

...it works as desired, though (the "#if TRACE" code doesn't execute).

Is it really necessary to undefine something that has not been defined (is commented out)? It seems bizarro.

2

There are 2 best solutions below

0
Mephy On BEST ANSWER

By default, in the profiles Debug and Release, Visual Studio will define the TRACE constant. You can change this behavior in the project settings (in the Build tab). The DEBUG constant is similar, active by default in the Debug profile (but not Release).

0
Lucas Trzesniewski On

TRACE is one of the two constants defined by default for debug builds:

TRACE