Initialisation of a Structure, Can anyone see the Obvious?
-
Hi, I have the following Code:
This refuses to compile with the following error message:
"error C2552: 'TestFieldItem' : non-aggregates cannot be initialized with initializer list".I must be doing something stupid, that I cannot see. Initialising Static Structures is the Cut and Trust of CPP!
Can anyone see the Obvious?:)
Bram van Kampen
-
Hi, I have the following Code:
This refuses to compile with the following error message:
"error C2552: 'TestFieldItem' : non-aggregates cannot be initialized with initializer list".I must be doing something stupid, that I cannot see. Initialising Static Structures is the Cut and Trust of CPP!
Can anyone see the Obvious?:)
Bram van Kampen
-
Hi, I have the following Code:
This refuses to compile with the following error message:
"error C2552: 'TestFieldItem' : non-aggregates cannot be initialized with initializer list".I must be doing something stupid, that I cannot see. Initialising Static Structures is the Cut and Trust of CPP!
Can anyone see the Obvious?:)
Bram van Kampen
As a side note, why declare each member as const? You could instead write ...
const struct DB_FIELD TestFieldItem =
{
"Key", // FieldName
NULL, // DesignerComment
0X00000000, // Field Flags
13, // Field Type
8, // Field Elt Size
1, //Field Elt Count
0, // Field Offset
0 //Padding Char
}; -
As a side note, why declare each member as const? You could instead write ...
const struct DB_FIELD TestFieldItem =
{
"Key", // FieldName
NULL, // DesignerComment
0X00000000, // Field Flags
13, // Field Type
8, // Field Elt Size
1, //Field Elt Count
0, // Field Offset
0 //Padding Char
};Point taken, and since discovered. There seems to be a C(PP) language ambiguity here, relating to aggregates. There is never a problem with:
const int Var=512;
Thanks for your reply, :)
Bram van Kampen
-
I just tried that and it compiled fine. Maybe there is something more that you are not showing us.
No, Not much more to show, just an Old Compiler! It Cannot handle these things, but I found a workaround. Was frightening at the time! Thanks, :)
Bram van Kampen