Yann Ylavic <yla...@apache.org> writes: > +#undef NDEBUG /* always abort() on assert()ion failure */ > +#include <assert.h>
Sorry for being late to the party, but I think there are a few problems with the "#undef NDEBUG" line: 1) The debug implementation of an assert() may print a diagnostic message, for example to stderr. A caller of the library function may not be ready for this to happen when using a non-debug version of the library. 2) The actual destination of the message seems to be implementation-defined. For example, in Windows-based applications this may show a message box [1], which is probably even more unexpected for the user of the library. 3) Undefining NDEBUG before other headers may silently cause unexpected effects if any of those headers make some decisions based on the NDEBUG value, which isn't an entirely unreasonable thing to expect. So, depending on whether we want the checks to soft- or hard-fault, maybe we could either remove the "#undef NDEBUG" line, or switch to a custom check that explicitly calls an abort()? [1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert#remarks Thanks, Evgeny Kotkov