Reputation: 3244
I apologize if this is a duplicate, but how do I define a preprocessor definition. In Visual Studio I can just go to C++ -> Preprocessor and set a list of definitions there. But I'm struggling with that in my Android gradle build.
I need to define DEBUG, as to satisfy the following condition
#if (!defined(NDEBUG)) && (!defined(DEBUG))
I've tried adding -DDEBUG, but that didn't seem to work. I've struggled finding documentation on what needs to be done.
cppFlags.addAll(["-fexceptions", "-std=gnu++11", "-DDEBUG"])
Here is my NDK build block // defines the NDK build ndk { moduleName "mymodule"
toolchain = "clang"
// If switching to GNU, here are the values to replace with
stl "gnustl_shared"
cppFlags.addAll(["-fexceptions", "-std=gnu++11", "-DDEBUG"])
// when adding system library dependencies, they are added here
ldLibs.addAll(["log","atomic"])
// C include directories
CFlags.addAll(["-I${file("src/main/jni/folder1")}".toString(),
"-I${file("src/main/jni/folder2")}".toString()
])
// C++ include directories
cppFlags.addAll(["-I${file("src/main/jni/morestuff")}".toString(),
])
}
Upvotes: 2
Views: 3265
Reputation: 1892
It looks like you have both CFlags
and cppFlags
set. Are you certain you are adding the DEBUG flag to the correct one? If you are dealing with a shared library, it may need your flag in CFlags
rather than cppFlags
.
I would try adding your DEBUG flag to CFlags
and see if that works:
CFlags.addAll(["-DDEBUG"])
Upvotes: 2