Abruzzo Forte e Gentile Abruzzo Forte e Gentile - 10 months ago 51
C Question

how to completely disable assertion

I have my code full of call to

In the debug version I use
g++ -g
exploiting my assertion.
With my surprise I can see assertion working also in my release version, the one compiled without

How can I completely disable at compile time my assertion? Should I explicitly define
in any build I produce despite they are debug,release or whatever any other?

Answer Source

You must #define NDEBUG (or use the flag -DNDEBUG with g++) this will disable assert as long as it's defined before the inclusion of the assert header file.