Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are we forced to use "-fexceptions" flag in android ndk project #640

Closed
CodeMasterYi opened this issue Jun 28, 2017 · 10 comments
Closed

Are we forced to use "-fexceptions" flag in android ndk project #640

CodeMasterYi opened this issue Jun 28, 2017 · 10 comments
Labels

Comments

@CodeMasterYi
Copy link

Are we forced to use "-fexceptions" flag in android ndk project?

@nlohmann nlohmann added platform: android related to Android NDK kind: question labels Jun 28, 2017
@nlohmann
Copy link
Owner

I am not using NDK myself. What happens if you do not provide the flags? What happens if you do?

@CodeMasterYi
Copy link
Author

CodeMasterYi commented Jun 29, 2017

I am not sure. I am not using "-fexceptions" flag in my ndk project.
try { json obj = json::parse("Hello, nlohmann::json!"); } catch (std::exception e) { CCLOG("json - ParseError: %s", e.what()); }
the CCLOG expression can never be touched, and the app crashed here! Crash Log's here:
A/libc: /tmp/ndk-cislave/tmp/build-7649/build-libc++/ndk/sources/cxx-stl/llvm-libc++/3.6/../../llvm-libc++abi/libcxxabi/src/cxa_personality.cpp:347: const __cxxabiv1::__shim_type_info *get_shim_type_info(uint64_t, const uint8_t *, uint8_t, bool, _Unwind_Exception *): assertion "ttypeEncoding == DW_EH_PE_absptr && "Unexpected TTypeEncoding"" failed

but the same code running on my ios project is ok! Log is like this:
Cocos2d: json::ParseError: std::exception

By the way, Is all exceptions throwed by methods of nlohmann::json derived from std::exception?

Thank you for your answering!

@nlohmann
Copy link
Owner

Yes, all exceptions inherit from std::exception. This won't change in 3.0.0, but then we use different exception classes.

I'm afraid I have too little NDK experience to help with the other issue.

@nlohmann
Copy link
Owner

nlohmann commented Jul 8, 2017

Which NDK are you using? As I wrote in the README, this seems to work:

APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := clang3.6
APP_CPPFLAGS += -frtti -fexceptions

@CodeMasterYi
Copy link
Author

CodeMasterYi commented Jul 8, 2017

Hi, Lohmann,
We use CrystaX NDK 10.3.2
in my Application.mk, we configure like this:

APP_STL := c++_shared
APP_CPPFLAGS := -std=c++11 -frtti -D__GNUC__=4
APP_PLATFORM := android-11
NDK_TOOLCHAIN_VERSION=4.9
APP_ABI := armeabi
#APP_ABI += armeabi-v7a
#APP_ABI += x86

and in Android.mk, we add this:

LOCAL_CFLAGS := -fexceptions

BUT this is of no effect!~~~

@nlohmann
Copy link
Owner

nlohmann commented Jul 8, 2017

Could you also add

LOCAL_CPP_FEATURES += exceptions

@CodeMasterYi
Copy link
Author

ok, i try it now!
(Which time zone are you in? I'm deep in the dark night! 😭 )

@CodeMasterYi
Copy link
Author

it is of no effect, either~~
i give up! i choose to use some extra verifications before parsing raw json string to avoid exceptions as possible.
Thank you~

@nlohmann
Copy link
Owner

nlohmann commented Jul 8, 2017

You're welcome. Sorry not being able to help you, though.

@cosmos33
Copy link

i run into same issue on Android platform。this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants