Will any exception be thrown when an attempt to allocate memory fails?
I just recently learned that exceptions are supported in Android.
I downloaded the ndk and found this in the docs folder, CPLUSPLUS-SUPPORT.HTML .
I. 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.
To enable it, use the '-fexceptions' C++ compiler flag. This can be done by adding the following to every module definition in your Android.mk:
LOCAL_CPPFLAGS += -fexceptions
More simply, add a single line to your Application.mk, the setting will automatically apply to all your project's NDK modules:
APP_CPPFLAGS += -fexceptions
NOTE: The obsolete "arm-eabi-4.4.0" toolchain provided for backwards compatibility with this NDK does not support exceptions!
So exceptions seems to be supported, as long as the application is compiled with '-fexceptions'. So my understanding is that code compiled with -fexceptions will throw std::bad_alloc on failure to allocate memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With