c++ - non-trivial designated initializers not supported -
i rebuilding library , found error in section of code:
enum fix_version { fix_4_0, fix_4_1, fix_4_2, fix_4_3, fix_4_4, fix_5_0, fixt_1_1, }; static const char *begin_strings[] = { [fixt_1_1] = "fixt.1.1", [fix_4_4] = "fix.4.4", [fix_4_3] = "fix.4.3", [fix_4_2] = "fix.4.2", [fix_4_1] = "fix.4.1", [fix_4_0] = "fix.4.0", };
the error receive is: sorry, unimplemented: non-trivial designated initializers not supported
. have seen other examples of error, initializers struct
, 1 simple char
, how can solve this? code comes .c
files , compiling in c++
through cmake
.
thank in advance.
the equivalent c++ code this:
enum fix_version { fix_4_0, fix_4_1, fix_4_2, fix_4_3, fix_4_4, fix_5_0, fixt_1_1 }; static const char *begin_strings[] = { "fix.4.0", "fix.4.1", "fix.4.2", "fix.4.3", "fix.4.4", 0, "fixt.1.1" };
this of course has risk forget fixing array when enum
changes. c++ doesn't support designated array initializers.
the better option, explained in comment, leave library as is , compile c compiler. if has headers using extern "c"
appropriate, can use directly c++ project. if not, place #include
s library in extern "c"
block.
Comments
Post a Comment