I have found a nice C++ library that I would like to use in my Swift package. However, the author defined a variable named "DEBUG". During compilation, I got:
xxx/CLaTeXMath/box/box.h:32:15: error: expected member name or ';' after declaration specifiers
static bool DEBUG;
~~~~~~~~~~~ ^
<command line>:3:15: note: expanded from here
#define DEBUG 1
Right now, the only workaround I can find is to define DEBUG as DEBUG in my Package.swift:
.target(
name: "CLaTeXMath",
dependencies: ["tinyxml2"],
cxxSettings: [
// It seems that the compiler defines "DEBUG" as 1 somewhere.
// There is a static variable named "DEBUG" in "box/box.h".
.define("DEBUG", to: "DEBUG"),
.headerSearchPath("."),
.unsafeFlags([
"-stdlib=libc++",
"-std=c++17",
""
]),
])
But then, I got flooded by the warning message:
In file included from <built-in>:425:
<command line>:3:9: warning: 'DEBUG' macro redefined [-Wmacro-redefined]
#define DEBUG DEBUG
^
<command line>:2:9: note: previous definition is here
#define DEBUG 1
^
1 warning generated.
I have two questions:
- Is the macro DEBUG automatically defined in Swift?
- What's the best way to approach this issue? Can I turn off this macro, or suppress the macro-redefined warning? Or should I just modify the source code?