📅 2015-Mar-16 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ assert, gcc ⬩ 📚 Archive
assert in C or C++ code is an excellent method to ensure correctness of pre-conditions and post-conditions in functions. Assertions are enabled by default in code compiled with GCC C and C++ compilers.
To disable assert,
NDEBUG must be defined. You can choose to define this in your code as
#define NDEBUG. Or you can pass
-DNDEBUG to the GCC compiler while compiling the code.
If you use CMake, you can add it to
CMakeLists.txt like this:
Tried with: CMake 22.214.171.124, GCC 4.9.2 and Ubuntu 14.04