Wes Miller
Wes Miller

Reputation: 2241

Eclipse/GCC Is there a DEBUG flag

I am using Eclipse for several C++ projects. I'd like to have some bits of purely debug code. I expected this to work:

#ifdef DEBUG
   do_something();
#endif

but, alas, DEBUG is undefined.

Is there another #defined "word" that means DEBUG? Or will I need to add a -DDEBUG to the compiler flags for the debug configuration.

Thanks!

Upvotes: 0

Views: 766

Answers (1)

rubenvb
rubenvb

Reputation: 76519

Standard C mentions NDEBUG in the context of <assert.h>; when it is defined, asserts do nothing.

Otherwise there is no standard macro, and the safest path is to define something yourself.

Upvotes: 1

Related Questions