When included, ucommon/ucommon.h (via platform.h) unexpectedly defines
NDEBUG without any warning, unless DEBUG has already been defined.

That led to a lot of head-scratching, trying to figure out why assert()
was sometimes, but not always, not doing its job while working on a
project that uses uCommon in some places.

(For the record, this was encountered in version 7.0.0, but seems to
have been present forever.)


 $ cat ucommon-ndebug.cpp
     #ifdef NDEBUG
     #warning "NDEBUG was already defined before including <ucommon/ucommon.h>"
     #endif
     
     #include <ucommon/ucommon.h>
     
     #ifdef NDEBUG
     #error "NDEBUG is defined after including <ucommon/ucommon.h>"
     #endif

 $ g++ -E ucommon-ndebug.cpp >/dev/null && echo OK
 ucommon-ndebug.cpp:8:2: error: #error "NDEBUG is defined after including 
<ucommon/ucommon.h>"
  #error "NDEBUG is defined after including <ucommon/ucommon.h>"
   ^~~~~

 $ g++ -E -DDEBUG ucommon-ndebug.cpp >/dev/null && echo OK
 OK


Reply via email to