Tag Archives: sorry, unimplemented: non-trivial designated initializers not supported

sorry, unimplemented: non-trivial designated initializers not supported

Why can’t you grab tickets when you travel on holiday?Reveal the key technology of 12306 how to ensure the ticket is not oversold>>>

The following error occurred when converting C language to C + + code

sorry, unimplemented: non-trivial designated initializers not supported。

The reason is that when initializing C + + structure, it must be initialized according to the defined order. It is not possible to initialize other options by skipping its contents, or there is a problem with the defined order

eg:

typedef struct command

{

int a;

char *b;

int c;

int d;

};

In the C language, it can be initialized when it is defined

struct command cmd = {

  .a = 20,

.c = 3,

};

In C + + language, errors will be reported. The modification method is as follows:

struct command cmd = {

  .a = 20,

. B = ‘,// must be initialized

.c = 3,

};

There is also a problem of order. The definition in C + + must be consistent with that in struct

eg:

struct command cmd = {

  .b = “fff”,

.a = 3,

};

C runs normally, while C + + runs abnormally, it will report title error and modify

struct command cmd = {

  .a = 3,

  .b = “fff”,

};