C++ / JNI brace-enclosed initializer Map (Android NDK)

Kévin Naudin

I have an engine write in C++ to integrate with JNI in AndroidStudio. 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):

The first one is initiazed with 2500 lines... The second one is like that :

std::map <StateEnum, std::string> StateToString = {
  { state_one, "State 1" },
  { state_two, "State 2" },
  { state_three, "State 3" },
  { state_four, "State 4" }
};

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>'

I tried also to compile c++ file to library then integrate it to my Android project. 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.

Dmitry Moskalchuk

STLport implementation is out-of-date and don't support C++11 (in particular, brace initializers). You should switch to GNU libstdc++ or LLVM libc++ implementation to get it working:

APP_STL := gnustl_static # GNU libstdc++
# Or:
APP_STL := c++_static    # LLVM libc++

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

c++ error: "array must be initialized with a brace-enclosed initializer"

From Dev

C++11 g++ with brace-enclosed initializer lists

From Dev

Initialize a class with brace-enclosed initializer list

From Dev

Brace Enclosed Initializer List? convert to vector

From Dev

Return brace-enclosed initializer list as struct

From Dev

Error: initializer must be brace-enclosed

From Dev

Initialize your class with constructor which takes std::map as a parameter with brace-enclosed initializer

From Dev

in C, why do I have " "s": initialization requires a brace-enclosed initializer list"?

From Dev

How to pass in a brace-enclosed initializer list to a function?

From Dev

Could not convert from brace-enclosed initializer list to std::vector

From Dev

Could not convert from brace-enclosed initializer list to std tuple

From Dev

Error when initializing a struct with a brace-enclosed initializer list

From Dev

Is it possible to use a brace-enclosed initializer list for a container of a container?

From Dev

could not convert {...} from <brace-enclosed initializer list> to struct

From Dev

cannot convert ‘<brace-enclosed initializer list>’ to ‘int*’ in initialization

From Dev

Why do brace-enclosed initializer lists not work for std::array

From Dev

Cannot convert to struct from brace-enclosed initializer list

From Dev

Could not convert from brace-enclosed initializer list

From Dev

Could not convert from <brace-enclosed initializer list> to int(*) array

From Dev

Callable class objects in C++ : no matching function for call to ‘std::tuple<T>::tuple(<brace-enclosed initializer list>)’

From Dev

Can I initialize an array using the std::initializer_list instead of brace-enclosed initializer?

From Dev

std::initializer_list not able to be deduced from <brace-enclosed initializer list>

From Java

Android ndk : Problem for call of Java method from c++ with jni

From Java

How to pass a complex structure between C and Java with JNI on Android NDK

From Dev

Unable to use brace enclosed initializer-list while inheriting from friend class

From Dev

no matching function for call to ‘std::vector::push_back(<brace-enclosed initializer list>)’

From Dev

Why can't I construct a gsl::span with a brace-enclosed initializer list

From Dev

Lvalue reference initialization from brace-enclosed initializer list fails to compile

From Dev

no matching function for call to ‘std::exception::exception(<brace-enclosed initializer list>)

Related Related

  1. 1

    c++ error: "array must be initialized with a brace-enclosed initializer"

  2. 2

    C++11 g++ with brace-enclosed initializer lists

  3. 3

    Initialize a class with brace-enclosed initializer list

  4. 4

    Brace Enclosed Initializer List? convert to vector

  5. 5

    Return brace-enclosed initializer list as struct

  6. 6

    Error: initializer must be brace-enclosed

  7. 7

    Initialize your class with constructor which takes std::map as a parameter with brace-enclosed initializer

  8. 8

    in C, why do I have " "s": initialization requires a brace-enclosed initializer list"?

  9. 9

    How to pass in a brace-enclosed initializer list to a function?

  10. 10

    Could not convert from brace-enclosed initializer list to std::vector

  11. 11

    Could not convert from brace-enclosed initializer list to std tuple

  12. 12

    Error when initializing a struct with a brace-enclosed initializer list

  13. 13

    Is it possible to use a brace-enclosed initializer list for a container of a container?

  14. 14

    could not convert {...} from <brace-enclosed initializer list> to struct

  15. 15

    cannot convert ‘<brace-enclosed initializer list>’ to ‘int*’ in initialization

  16. 16

    Why do brace-enclosed initializer lists not work for std::array

  17. 17

    Cannot convert to struct from brace-enclosed initializer list

  18. 18

    Could not convert from brace-enclosed initializer list

  19. 19

    Could not convert from <brace-enclosed initializer list> to int(*) array

  20. 20

    Callable class objects in C++ : no matching function for call to ‘std::tuple<T>::tuple(<brace-enclosed initializer list>)’

  21. 21

    Can I initialize an array using the std::initializer_list instead of brace-enclosed initializer?

  22. 22

    std::initializer_list not able to be deduced from <brace-enclosed initializer list>

  23. 23

    Android ndk : Problem for call of Java method from c++ with jni

  24. 24

    How to pass a complex structure between C and Java with JNI on Android NDK

  25. 25

    Unable to use brace enclosed initializer-list while inheriting from friend class

  26. 26

    no matching function for call to ‘std::vector::push_back(<brace-enclosed initializer list>)’

  27. 27

    Why can't I construct a gsl::span with a brace-enclosed initializer list

  28. 28

    Lvalue reference initialization from brace-enclosed initializer list fails to compile

  29. 29

    no matching function for call to ‘std::exception::exception(<brace-enclosed initializer list>)

HotTag

Archive