non-trivial designated initializers not supported
Posted 奇妙之二进制
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
以上是关于non-trivial designated initializers not supported的主要内容,如果未能解决你的问题,请参考以下文章
sorry, unimplemented: non-trivial designated initializers not supported
[译]A NON-TRIVIAL EXAMPLE OF MEDIATR USAGE
Python 进程 TypeError: no default __reduce__ due to non-trivial __cinit__
Prototype design pattern in Java