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

后端 未结 5 1832
长情又很酷
长情又很酷 2021-02-19 10:53

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

// Spreadsheet structure
typedef struct SPREADSHEET
{    
      int ID         


        
相关标签:
5条回答
  • 2021-02-19 11:20

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

    0 讨论(0)
  • 2021-02-19 11:36

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

    typedef struct BLAH { ... } BLAH;
    
    0 讨论(0)
  • 2021-02-19 11:36

    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 ;.

    0 讨论(0)
  • 2021-02-19 11:42

    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;
    
    0 讨论(0)
  • 2021-02-19 11:43

    My interpretation of this warning is that the compiler is indicating that the typedef keyword is unnecessary because a variable is not being declared. and therefore if the intention of the code is to simply declare a struct the typedef is superfluous.

    0 讨论(0)
提交回复
热议问题