如果这是重复的,我深表歉意,但是我如何定义预处理器定义。在 Visual Studio 中,我只需转到 C++ -> 预处理器并在那里设置定义列表。但我在 Android gradle 构建中遇到了这个问题。
我需要定义DEBUG,以满足以下条件
#if (!defined(NDEBUG)) && (!defined(DEBUG))
我尝试添加 -DDEBUG,但这似乎不起作用。我一直在努力寻找有关需要做什么的文档。
cppFlags.addAll(["-fexceptions", "-std=gnu++11", "-DDEBUG"])
这是我的 NDK 构建 block //定义 NDK 构建 NDK { 模块名称“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(),
])
}
最佳答案
看起来您已设置了 CFlags
和 cppFlags
。您确定将 DEBUG 标志添加到正确的标志吗?如果您正在处理共享库,它可能需要 CFlags
中的标志,而不是 cppFlags
。
我会尝试将您的 DEBUG 标志添加到 CFlags
中,看看是否有效:
CFlags.addAll(["-DDEBUG"])
关于android - 如何在 Gradle 中设置预处理器定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41284920/