Microsoft KB Archive/139871

= FIX: Error C2371 on Struct Typedef that Does Not Have a Tag =

Article ID: 139871

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft Visual C++ 2.0 Professional Edition, when used with:
 * Microsoft Windows NT 4.0
 * Microsoft Visual C++ 2.1, when used with:
 * Microsoft Windows NT 4.0
 * Microsoft Visual C++ 2.2, when used with:
 * Microsoft Windows NT 4.0
 * Microsoft Visual C++ 4.0 Standard Edition, when used with:
 * Microsoft Windows NT 4.0
 * Microsoft Visual C++ 4.1 Subscription, when used with:
 * Microsoft Windows NT 4.0
 * Microsoft Visual C++ 4.2 Professional Edition, when used with:
 * Microsoft Windows NT 4.0

-



This article was previously published under Q139871



SYMPTOMS
If you have a typedef for a structure that doesn't have a tag, you may receive the following error when you compile the code:

Error C2371: ' ' : redefinition; different basic types



RESOLUTION
Include a tag for the structure.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0.



Sample Code to Reproduce Problem
/* Compile options needed: none */

class A  { public: const A& operator=(const A&); };

typedef struct // add tag here {     A a;   } B;

B t1, t2;

void f {    t2 = t1; }

void main {     f; }

Keywords: kbbug kbfix kblangcpp kbvc500fix KB139871

-

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

© Microsoft Corporation. All rights reserved.