I downloaded ndk and found this in the docs folder, CPLUSPLUS-SUPPORT.HTML.
I. Support for C ++ Exceptions:
The NDK toolchain supports C ++ exceptions since NDK r5, however, all C ++ sources are compiled with -fno-exceptions support by default, for compatibility with previous versions.
To enable it, use the C ++ compiler flag '-fexceptions'. This can be done by adding the following to each module definition in your Android.mk:
LOCAL_CPPFLAGS += -fexceptions
Simply put, add one line to your Application.mk, the configuration will be automatically applied to all your NDK project modules:
APP_CPPFLAGS += -fexceptions
NOTE. The legacy "arm-eabi-4.4.0" toolchain provided for backward compatibility with this NDK does not support exceptions!
Thus, exceptions appear to be supported if the application is compiled with '-exceptions'. Therefore, I understand that code compiled with -fexceptions will call std :: bad_alloc when the memory allocation fails.
Anton
source share