eonil
eonil

Reputation: 85955

Is there standard of debug mode compilation flag in C compiler?

Is there any pre-defined flag by standard specification (ANSI/C89/C99) for debug-mode-compilation in C compiler?

I know DEBUG and NDEBUG flags, but I am not sure about whether they're in the C standard or not.

Upvotes: 0

Views: 1194

Answers (2)

Michael Entin
Michael Entin

Reputation: 7724

That really depends on what you call - "debug mode compilation". It can mean lots of different things to different people:

  1. no optimizations, so code can be more easily debugged
  2. debug symbol generation, again to help debugger
  3. usage of assert function
  4. compiling with debug libraries, that do additional runtime checking
  5. usage of other custom debugging techniques

The NDEBUG controls the bullet #3 only. Of course it is often combined with others, because it makes sense to use them together. But nothing forces you to use all of them - you may define various combinations of these things, e.g. optimized build with assert checks, etc.

Upvotes: 3

Jerry Coffin
Jerry Coffin

Reputation: 489988

No -- whether NDEBUG is defined or not is used in the standard to determine what assert expands to, but there's nothing about what causes it to be defined. At least to my recollection, there's nothing about anything named DEBUG at all.

Upvotes: 3

Related Questions