Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exit an android NDK application

I'm making my own assert macro using Android NDK in C++ like in this answer, but there is an std::exit function that can not be used in Android. Is there some alternative like std::exit in Android?

like image 284
Tom Avatar asked Jul 22 '14 19:07

Tom


Video Answer


1 Answers

Had a similar requirement and found std::terminate works. In particular, on iOS (and quite likely Android) it causes a "forced" crash which Application Performance Management Tools (aka Crash Loggers) like Crashlytics would pick up and report.

  • Evidence that Android handles std::terminate: https://android.googlesource.com/platform/ndk.git/+/429798ff636b0553e4ff3c692067718caa9c454e/sources/cxx-stl/gabi++/src/terminate.cc

Additional Reference:

  • http://www.cplusplus.com/reference/exception/terminate/
  • http://en.cppreference.com/w/cpp/error/terminate
like image 146
Dannie Avatar answered Oct 04 '22 06:10

Dannie