How can I remove the VS warning C4091: 'typedef ' : ignored on left of 'SPREADSHEET' when no variable is declared

35,747

Solution 1

Delete typedef. It's the C way of declaring structs, C++ does it automatically for you.

Solution 2

You need to add some identifier before the terminating ;, e.g.:

typedef struct BLAH { ... } BLAH;

Solution 3

Just remove "typedef". You declare a new struct and the typedef keyword isn't used for that. You would use typedef to define a new name for an existing type, like this:

typedef int number;

Solution 4

Yes, the BLAH after the closing brace is important to make the typedef a valid one. You can remove the SPREADSHEET from the present place and keep it in between the } and the ;.

Share:
35,747
Wartin
Author by

Wartin

Updated on August 12, 2020

Comments

  • Wartin
    Wartin almost 4 years

    This warning is triggered multiple times in my code by the same declaration, which reads :

    // Spreadsheet structure
    typedef struct SPREADSHEET
    {    
          int ID;               // ID of the spreadsheet    
          UINT nLines;          // Number of lines
    
          void CopyFrom(const SPREADSHEET* src)
          {
               ID = src->ID;
               nLines = src->nLines;
          }
    };
    

    I don't want to just turn off that warning,

    but rather change the code so that the warning doesn't come up !

    NOTE : I don't want to declare any variables here (it's a header file), only define what the struct 'SPREADSHEET' should include...