What is the meaning of `struct X typedef` vs. `typedef struct X`?

前端 未结 5 1913
走了就别回头了
走了就别回头了 2020-12-03 13:03

I have the following (working) code in an existing code base, used in include file that is shared between C and C++, compiling on MSVC (2010) and Windows DDK:



        
5条回答
  •  既然无缘
    2020-12-03 13:52

    Both have the same meaning. Both of these two forms are valid:

    typedef  
     typedef    
    

    You can typedef the above struct in either ways:

    struct X {
        USHORT x;
    }typedef X, *PX;     //  typedef  
    

    or

    typedef struct {
        USHORT x;
    } X, *PX;            // typedef  
    

提交回复
热议问题