#947145 libucommon-dev: #include <ucommon/ucommon.h> unexpectedly defines NDEBUG

Package:
libucommon-dev
Source:
ucommon
Description:
lightweight C++ threading and sockets - development files
Submitter:
Frédéric Brière
Date:
2019-12-21 23:27:09 UTC
Severity:
normal
#947145#5
Date:
2019-12-21 21:54:44 UTC
From:
To:
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.


 $ 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