[英]Detect stdint.h and C++11 on android NDK
I found somewhere that i could detect C++11 using the following line : 我发现可以使用以下行检测到C ++ 11:
#if __cplusplus <= 199711L
I'm using this to conditionally defined fixed-width types such as int32_t or uchar16_t, etc... 我正在使用它来有条件地定义固定宽度类型,例如int32_t或uchar16_t等。
The problem is that when using the android NDK, __cplusplus
is defined as 1
. 问题是,当使用android NDK时,
__cplusplus
定义为1
。 Is there a more portable way to detect C++11 and the presence of stdint.h to avoid redefinitions ? 有没有更便捷的方法来检测C ++ 11和stdint.h的存在,以避免重新定义?
Thank you. 谢谢。
For me it always works: 对我而言,它始终有效:
$ CXX=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++
$ $CXX -x c++ -E -dM /dev/null | grep __cplusplus
#define __cplusplus 199711L
$ $CXX -x c++ -std=c++11 -E -dM /dev/null | grep __cplusplus
#define __cplusplus 201103L
The same for LLVM toolchain: LLVM工具链也是如此:
$ CXX="$NDK/toolchains/llvm-3.5/prebuilt/darwin-x86_64/bin/clang++ -target armv7-none-linux-androideabi"
$ $CXX -x c++ -E -dM /dev/null | grep __cplusplus
#define __cplusplus 199711L
$ $CXX -x c++ -std=c++11 -E -dM /dev/null | grep __cplusplus
#define __cplusplus 201103L
I've tried it with NDK r10d and r10e, and it works in both of them, so there is definitely something wrong with your setup. 我已经使用NDK r10d和r10e对其进行了尝试,并且它们在它们两者中均有效,因此您的设置肯定存在问题。 I could say more if you'd provide minimal project where such problem exist.
如果您提供存在此类问题的最少项目,我可以说更多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.