Microsoft KB Archive/201830

= BUG: Error C2011 When Reusing Nested Structure Tag Names =

Article ID: 201830

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q201830



SYMPTOMS
When the same tag name is used to declare nested structures inside different base structure declarations, the follow error is generated:

error C2011: ' ' : ' ' type redefinition

NOTE: The C++ compiler does not generate this error.



RESOLUTION
To work around this problem, either don't use tag names for nested structures, or use unique tag names for all structures.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



MORE INFORMATION
The following code fails to compile with the C compiler. Error C2011 is reported at the second use of "tag_LEVEL2" and "tag_LEVEL3". This error does not occur using the C++ compiler.

/* Defining "A" structure */ struct tag_STRUCTA {

struct tag_LEVEL2 { int  member_a2;

struct tag_LEVEL3 { int member_a3; };  }; };

/* Defining "B" structure */ struct tag_STRUCTB {

struct tag_LEVEL2 { int  member_b2; };  struct tag_LEVEL3 { int member_b3; }; };

Keywords: kbbug kbnofix kbconly KB201830

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.