morganstanley/modern-cpp-kafka

DEBUG conflicts with commonly-defined macro

jzakrzewski opened this issue · 3 comments

This:

static const constexpr char* DEBUG = "debug";

causes:

: error: expected unqualified-id before numeric constant
kafka/ClientConfig.h:77:34: note: in expansion of macro ‘DEBUG’
77 | static const constexpr char *DEBUG = "debug";

While, even the macro (might be from windows?) is "comonly-defined", doesn't mean it's not guilty. 😅
A workaround would be usingundef before including the ClientConfig.h.
E.g.

#ifdef DEBUG
#undef DEBUG
#endif

#include <kafka/ClientConfig.h>
...

It's not so easy - our project actually relies on this macro. This also why UPPERCASE_IDENTIFIERS should be reserved to macros only - there are just too many possible conflicts.

BTW: This is not the first time this has been reported. See: #127

BTW: This is not the first time this has been reported. See: #127

OH, yes, it comes back to KafkaClient.h via the included headers, -- so anyway you can't get rid of the ClientConfig.h.
Maybe we should just remove the DEBUG from kafka::clients::Config.