0

I have a logging facility which is basically a wrapper around glog + some utility functions which I regularly need. This code is in use for quite some time and compiles on different platforms (Intel Mac, Ubuntu, Debian) and compilers (gcc, clang) just fine. However, I cannot get the code compiled on Alpine with musl.

The error is as follows:

src/../include/Logging.hpp:52:30: error: expected primary-expression before 'while'
   52 | #define myAssert(condition) DCHECK(condition)
      |                              ^~~~~~

The macro in my Logging.hpp is defined as follows:

// Only gets compiled for debug configuration
#define myAssert(condition) DCHECK(condition)

There are a bunch of macros relating to DCHECK in glog's logging.h file, thus I just link the related file: https://github.com/google/glog/blob/master/src/glog/logging.h.in

Relevant should be the following lines:

Why doesn't that work as expected? The only thing I see as potential candidate is this GLOG_MSVC_PUSH_DISABLE_WARNING, but this also expands to a no-op.

benjist
  • 2,740
  • 3
  • 31
  • 58

1 Answers1

0

For anyone ever seeing this issue: Check if you use the log macro in debug mode as part of an initializer list where you assert not null before assigning the memory of a pointer to a member variable. Example:

explicit MyClass(std::shared_ptr<const data::SomeObject> objectPtr)
            : memberVar((myCheck(objectPtr), *objectPtr)) 
{ }

private:
    data::SomeObject objectPtr;

Notice the assert within the initializer list. If this evaluates to empty in release mentioned error will be thrown. It all makes sense, but glog has quite a few ways to evaluate this macro.

benjist
  • 2,740
  • 3
  • 31
  • 58