[英]C++ / JNI brace-enclosed initializer Map (Android NDK)
I have an engine write in C++ to integrate with JNI in AndroidStudio. 我有一个用C ++编写的引擎,可与AndroidStudio中的JNI集成。 I read & follow all tutorials I found.
我阅读并遵循我发现的所有教程。
In the Cpp file there is header's import which include 2 maps brace-enclosed initialized like that (just example): 在Cpp文件中,有标头的导入,其中包括2个用括号括起来的映射,初始化方式如下(仅此示例):
The first one is initiazed with 2500 lines... The second one is like that : 第一个启动了2500行...第二个是这样的:
std::map <StateEnum, std::string> StateToString = {
{ state_one, "State 1" },
{ state_two, "State 2" },
{ state_three, "State 3" },
{ state_four, "State 4" }
};
Application.mk Application.mk
APP_ABI := all
APP_STL := stlport_static
APP_CFLAGS := -std=c++11 -fPIC
And here is the error : 这是错误:
jni/My_header.h:line: error: could not convert '{{state_one, "State 1"}, {state_two, "State 2"}..} from '< brace-enclosed initializer list>' to 'std::map< StateEnum, std::string>'
jni / My_header.h:行:错误:无法将'{{state_one,“状态1”}},{state_two,“状态2”} ..}从'<大括号括起来的初始化器列表>'转换为'std :: map <StateEnum,std :: string>'
I tried also to compile c++ file to library then integrate it to my Android project. 我还尝试将c ++文件编译为库,然后将其集成到我的Android项目中。 And the result is same.
结果是一样的。
Anyone can help me. 任何人都可以帮助我。 I didn't want to translate 2500 lines of map initialization (with map.add(...)) into 5000 lines.
我不想将2500行的地图初始化(使用map.add(...))转换为5000行。
STLport implementation is out-of-date and don't support C++11 (in particular, brace initializers). STLport实现已过时,并且不支持C ++ 11(特别是大括号初始化程序)。 You should switch to GNU libstdc++ or LLVM libc++ implementation to get it working:
您应该切换到GNU libstdc ++或LLVM libc ++实现以使其运行:
APP_STL := gnustl_static # GNU libstdc++
# Or:
APP_STL := c++_static # LLVM libc++
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.