我在 Android Native Development Kit Cookbook 中读到:
By default, Android provides minimal C++ support. There's no Run-time Type Information (RTTI) and C++ exceptions support, and even the C++ standard library support, is partial. The following is a list of the C++ headers supported by Android NDK by default:
cassert, cctype,cerrno, cfloat, climits, cmath, csetjmp, csignal, cstddef, cstdint, cstdio, cstdlib, cstring, ctime, cwchar, new, stl_pair.h, typeinfo, utility
It is possible to add more C++ support by using different C++ libraries. NDK comes with the gabi++, stlport, and gnustl C++ libraries, besides the system default one. In our sample code, we used an external "C" to wrap the C++ method. This is to avoid C++ mangling of the JNI function names. C++ name mangling could change the function names to include type information about parameters, whether the function is virtual or not, and so on. While this enables C++ to link overloaded functions, it breaks the JNI function discovery mechanism.
We can also use the explicit function registration method covered in the Loading native libraries and registering native methods recipe of Chapter 2, Java Native Interface, to get rid of the wrapping.
如果在应用程序的逻辑中使用了 RTTI 那么它就不能在 android 上运行吗?
最佳答案
您可以打开它,默认情况下它是关闭的。要打开它,请将 LOCAL_CPPFLAGS += -frtti
添加到您的 makefile。与往常一样,打开此标志的代码将占用更多内存,磁盘空间更大,并且比关闭它的代码稍微慢一些。
关于android - 如果我的代码使用 RTTI 那么它不能在 android 上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23976633/