bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

#include <ucommon/ucommon.h> unexpectedly defines NDEBUG


From: Frédéric Brière
Subject: #include <ucommon/ucommon.h> unexpectedly defines NDEBUG
Date: Sat, 21 Dec 2019 17:04:35 -0500
User-agent: Mutt/1.10.1 (2018-07-13)

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

[Prev in Thread] Current Thread [Next in Thread]