This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Is there a parameter called _DEBUG?


Hi George,

The _DEBUG define is (as far as I am aware) a Microsoft-ism convention.
Some people have taken that convention to heart, and rely upon it in their
own environments -- even non-Microsoft environments.

For debug builds, the _DEBUG is defined.  Caution:  in C++, _DEBUG is a
reserved identifier, use at your own peril.  (Microsoft legitimately uses it
in their compiler, since those kind of identifiers are reserved for the
compiler vendor to use as they see fit.)

For non-debug builds (release builds), the NDEBUG is defined.  Note:  NDEBUG
has a long history in C.  Look at the "assert.h" header.  I believe NDEBUG
is used on every platform that supports C/C++.  If an "NDEBUG" symbol were
to be introduced today, it would be _NDEBUG, but because of its provenance,
it is NDEBUG.

I recommend using the presence or absence of NDEBUG as the trigger for code
that is release (#ifdef NDEBUG) or debug (#ifndef NDEBUG).  Even thought I
have a bit of distaste for "#ifndef NDEBUG" because of the double-negative
makes my tiny little brain hurt.

HTH,
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]