Re: Is there a parameter called _DEBUG?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux