Issue
Will any exception be thrown when an attempt to allocate memory fails?
I just recently learned that exceptions are supported in Android.
Solution
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 += -fexceptionsMore simply, add a single line to your Application.mk, the setting will automatically apply to all your project's NDK modules:
APP_CPPFLAGS += -fexceptionsNOTE: 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.
Answered By - Anton
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.