Search code examples
c++exceptionwxwidgetsassertionsuppress

C++ suppress assertions in debug build


I have my wxWidgets client/server application and faced a complicated bug inside wxWidgets network stuff. It's a long story, let's skip it here.

wxWidgets code uses assertion, so I can't catch it as if it was an exception.

Can I suppress assertions while still compiling in debug mode?

Every time assertion happens, there is wxWidget's assertion info window appears, so user needs to press "Continue" or "Abort" button. If I can't catch it (assertion is not an exception), I'd like to suppress it.


Solution

  • If you are talking about standard assert macro, you can turn it off by defining NDEBUG macro.

    If NDEBUG is defined as a macro name at the point in the source code where <cassert> is included, then assert does nothing.