After reading the Android NDK documentation i am a bit confused on this issue. The CPLUSPLUS-SUPPORT.html states that:
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.
However, STANDALONE-TOOLCHAIN.html says:
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).
These two statements seem to be in complete contradiction of each other. Or have I misunderstood something? So are exceptions enabled or disabled by default? Or does it perhaps depend on some other factor?
My guess is the one of the documents has simply been carried over from an older release and that is the reason for the discrepancy but I would like to know which is correct.
If you are using the provided
ndk-buildsystem to build your apps (which you probably are) then exceptions are disabled by default.STANDALONE-TOOLCHAIN.htmlonly applies if you’re using the compiler directly with your own build system, rather than usingndk-build. Here’s what it says: