Does GCC have any built-in DEBUG preprocessor flags?

Joseph D. Wagner wagnerjd@prodigy.net
Fri Dec 6 09:43:00 GMT 2002


I'm wondering if GCC automatically defines any preprocessor DEBUG flags when
executed with the -g option.

For example, when a program compiles on Microsoft Visual C++ in Debug mode,
the compiler automatically defines _DEBUG as a preprocessor flag, which can
be tested by preprocessor statements like:
#ifdef _DEBUG.

I'm wondering if GCC does something similar.

I devised the attached code to test if GCC does something like this.  I
compiled using the command:

gcc -g -o DebugTest.bin DebugTest.cpp

When I ran DebugTest.bin, I received the following output:

DebugTest Completed.

When I compile and run the same code with Microsoft Visual C++, I get:

Uses: _DEBUG
DebugTest Completed.

So did my test conclusively demonstrate that GCC doesn't automatically
define preprocessor DEBUG flags, or am I missing something?  (Or should I be
using a different -g flag?)

Joseph Wagner
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: DebugTest.cpp
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20021206/502d4740/attachment.ksh>


More information about the Gcc-help mailing list