Wednesday, March 17, 2010

C++ note: enabling and disabling assert

In C++, assert is by default compiled. To exclude it, the macro NDEBUG must be defined when assert.h is included. This can be done by using -DNDEBUG compiler option or #define NDEBUG in code.

gcc -DNDEBUG -c test.cpp -o test.o

No comments: