C/C++编译错误收集non-trivial designated initializers not supported
Posted 奇妙之二进制
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C/C++编译错误收集non-trivial designated initializers not supported相关的知识,希望对你有一定的参考价值。
the order of initialization needs to be in the exact order of declaration.
typedef struct FOO
int a;
int b;
int c;
FOO;
FOO foo = .a = 1, .b = 2; // OK
FOO foo1 = .a = 1; // OK
FOO foo2 = .b = 2, .a = 1; // Error sorry, unimplemented: non-trivial designated initializers not supported
FOO foo3 = .a = 1, .c = 2; // Error sorry, unimplemented: non-trivial designated initializers not supported
解释:
I understand that this means that the compiler has no support for name-oriented, out-of-order, member initialization.
Need to initialize the struct in the old fashioned way. I keep the variable names for clarity, but I have to initialize them in order, and not skip a variable.
I can stop the initialization at any variable, but can’t initialize variables that come of that.
解决方法:
Assign to .name=value fields
Assign in the order they where declared
Include all fields in the assigment
以上是关于C/C++编译错误收集non-trivial designated initializers not supported的主要内容,如果未能解决你的问题,请参考以下文章
C/C++编译错误收集error: jump to label ‘XXXX’ [-fpermissive]
C/C++编译错误收集-Wnon-virtual-dtor持有虚函数却不是虚析构
c/c++编译错误收集error: jump to case label
c/c++编译错误收集error: jump to case label [-fpermissive] crosses initialization of ‘xxx‘
sorry, unimplemented: non-trivial designated initializers not supported