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

ID: Q139871


The information in this article applies to:
  • Microsoft Visual C++ 32-bit Edition, versions 2.0, 2.1, 2.2, 4.0, 4.1, 4.2
    on the following platforms: WINDOWS


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: '<typedef tag>' : 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.


MORE INFORMATION

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();
   }
   \* 

Additional query words: kbVC400bug

Keywords : kbLangCPP kbVC kbVC500fix
Version : :2.0,2.1,2.2,4.0,4.1,4.2
Platform : NT WINDOWS
Issue type : kbbug


Last Reviewed: February 2, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.