简体   繁体   English

C ++ / JNI大括号括起来的初始值设定项映射(Android NDK)

[英]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.

相关问题 C++ 默认大括号括起来的初始化列表 - C++ default brace-enclosed initializer list 数组必须用大括号括起来的初始化程序 c++ 初始化 - array must be initialized with a brace-enclosed initializer c++ c++ 错误:“数组必须用大括号括起来的初始化器初始化” - c++ error: "array must be initialized with a brace-enclosed initializer" 用大括号括起来的初始化程序列表 - brace-enclosed initializer list 无法将…转换为&#39; <brace-enclosed initializer list> 到地图 - could not convert … from '<brace-enclosed initializer list>' to map 无法从 '<brace-enclosed initializer list> ' 到 map</brace-enclosed> - could not convert from ‘<brace-enclosed initializer list>’ to map C ++函数错误-无法将括号括起来的初始化程序列表转换为char * - C++ Function error — could not convert brace-enclosed initializer list to char* 来自大括号括起的初始值设定项列表的短 C++ 类构造函数 - Short c++ class constructor from brace-enclosed initializer list C++ 中的动态嵌套 arrays 导致无法将大括号括起来的初始值设定项列表转换为 int - Dynamic nested arrays in C++ resulting in cannot convert brace-enclosed initializer list to int 带有括号括起来的初始化程序列表的C ++ 11 g ++ - C++11 g++ with brace-enclosed initializer lists
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM