如何在 C/C++ 文件中检测 Android NDK 的编译? [英] How to detect compilation by Android NDK in a C/C++ file?
本文介绍了如何在 C/C++ 文件中检测 Android NDK 的编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一个预处理器宏可以让我知道 NDK 正在编译我的代码?我可以手动定义自己的,但如果可能的话我宁愿不要.
Is there a preprocessor macro that will let me know NDK is compiling my code? I could manually define my own, but I'd rather not if possible.
推荐答案
运行预处理器看到的是#ifdef __ANDROID__
:
It is #ifdef __ANDROID__
as seen by running the preprocessor:
~$ /usr/local/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -E -dM - < /dev/null | grep -i android
输出是:
#define __ANDROID__ 1
无需依赖在项目中定义内容,尤其是在您跳过 NDK 构建系统时.
No need to depend on defining stuff in your project especially if you're skipping the NDK build system.
这篇关于如何在 C/C++ 文件中检测 Android NDK 的编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文