C++ programs (like C) usually have different build configurations based on preprocessor macros, which can be passed from the command line.
The canonical debug mode flag is the macro NDEBUG
, which if defined means you are not in debug mode. (It could be more clearly named PRODUCTION
, but sadly it's named in terms of what it's not.)
NDEBUG
is standard, and ancient. It is used by the <cassert>
header, which is known as <assert.h>
in C. Its official function is to make the assert
macro into a no-op, but it also usually affects the C++ standard library in terms of checking bounds and requirements.
For example, g++ -DNDEBUG myProg.cpp -o myProg
should compile without runtime features related to debugging.
Note that this is different from producing symbolic support for the debugger, which is controlled with -g
on GCC, or other flags for other platforms.