阅读 Android NDK 文档后,我对这个问题有点困惑。 CPLUSPLUS-SUPPORT.html 指出:
II.1. C++ Exceptions support:
The NDK toolchain supports C++ exceptions, since NDK r5, however all C++ sources are compiled with -fno-exceptions support by default, for compatibility reasons with previous releases.
但是,STANDALONE-TOOLCHAIN.html 说:
5.3 Exceptions, RTTI and STL:
The toolchain binaries do support C++ exceptions and RTTI by default. They are enabled by default, so use -fno-exceptions and -fno-rtti if you want to disable them when building sources with them (e.g. to generate smaller machine code).
这两个说法似乎完全矛盾。还是我误解了什么?那么异常是默认启用还是禁用?还是取决于其他因素?
我的猜测是其中一份文件只是从旧版本中继承下来的,这就是造成差异的原因,但我想知道哪个是正确的。
最佳答案
如果您正在使用提供的 ndk-build
系统来构建您的应用程序(您可能就是这样),那么默认情况下禁用异常。
STANDALONE-TOOLCHAIN.html
仅在您直接将编译器与您自己的构建系统一起使用时适用,而不是使用 ndk-build
。内容如下:
It is now possible to use the toolchains provided with the Android NDK as standalone compilers. This can be useful if you already have your own build system, and only need to ability to invoke the cross-compiler to add support to Android for it.
关于android - 默认情况下,Android NDK 工具链二进制文件构建时有无异常(exception)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9497289/