Android NDK R5 and support of C++ exception

前端 未结 4 1580
借酒劲吻你
借酒劲吻你 2020-12-06 01:48

I am trying to use the NDK 5 full C++ gnustl:

The CPLUSPLUS-SUPPORT.html states:

The NDK toolchain supports C++ exceptions, since

相关标签:
4条回答
  • 2020-12-06 02:00

    The NDK-r5 tools support the use of exceptions and RTTI in C++ code. The use of an STL other than the GNU STL as a static library is not, however, supported, in the presence of RTTI or exceptions.

    The STLport supplied is not usable together with exceptions or RTTI.

    Note that it may be necessary to clean the build objects when swapping between STL implementations.

    0 讨论(0)
  • 2020-12-06 02:07

    As far as I know, the Android NDK has never supported exceptions. libstdc++ itself does support exceptions, but when compiled for android, exception support is turned off (grep for "-fno-exceptions").

    See this thread on the android ndk mailing list.

    0 讨论(0)
  • 2020-12-06 02:22

    I have a similar problem using JNI. All exceptions thrown from a JNI method are causing a SIGILL error under Android 1.6 and 2.1. It's working fine under Android 2.2+

    See my issue (please don't hesitate to vote for it or post a comment) :

    http://code.google.com/p/android/issues/detail?id=20176

    So, currently, Android 1.6 and 2.1 don't support exceptions from JNI methods with the last NDK.

    Perhaps could it be fixed in a future NDK release...

    0 讨论(0)
  • 2020-12-06 02:24

    It turns out that exceptions work but only if the exception are inherited from std::exception. In my case the exception hierarchy did not always include std::exception which broke the catch/throw. Curiously the throwing strings as exceptions works when compiled for x86/Mac OS. I have fixed my problem by modifying the exceptions I use.

    0 讨论(0)
提交回复
热议问题