Cannot Initialize Union Containing Nameless Struct Member

ID Number: Q65392

6.00 6.00a 6.00a | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 buglist6.00 buglist6.00ax

Summary:

The Microsoft C Compiler versions 6.0, 6.0a, and 6.0ax produce one of

the following errors when a union containing a nameless struct as one

of its members is initialized:

error C2097: illegal initialization

error C2078: too many initializers

The sample code below illustrates this problem: The only workarounds

available are to either name the struct or to leave the union

uninitialized.

Microsoft has confirmed this to be a problem in C versions 6.0, 6.0a,

and 6.0ax. We are researching this problem and will post new

information here as it becomes available.

Sample Code

-----------

/* Compile options needed: none

*/

union

{

struct

{

int a;

int b;

}; // Add a name here to allow initialization

long c;

} x = {{ 0,0 }};

Additional reference words: 6.00 6.00a 6.00ax