PRB: Nested Nameless Structs Can Cause C2030 Error

ID Number: Q64686

6.00 6.00a 6.0ax 7.00 | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 buglist6.00a buglist6.00ax buglist7.00

Summary:

SYMPTOMS

In Microsoft C versions 6.0, 6.0a, 6.0ax, and 7.0, using the same

nameless structure as a member of two different structures will

cause the compiler error:

C2030: 'varname': struct/union member redefinition.

The code sample below reproduces the error:

STATUS

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

6.0a, 6.0ax, and 7.0. We are researching this problem and will post

new information here when it becomes available.

More Information:

Sample Code

-----------

#include <stdio.h>

void main(void)

{

struct s1

{

int a,b,c;

};

struct s2

{

struct s1;

float y;

char str[10];

} *p_s2;

struct s3

{

struct s1;

float z;

char a[10];

} *p_s3;

}

The error message names the structure member following the nameless

struct. A second nameless struct may be used only if it contains

different fields than the first nameless struct.

Examples of nameless structures and unions are given on page 434 of

the "Microsoft C Advanced Programming Techniques" manual for C version

6.0. There is also mention of this problem in the README.DOC file.

Additional reference words: 6.00 6.00a 6.00ax C++ 7.00