Differences between struct in C and C++

后端 未结 5 2216
鱼传尺愫
鱼传尺愫 2020-12-20 11:55

I am trying to convert a C++ struct to C but keep getting "undeclared identifier"? Does C++ have a different syntax for referring to structs?

struc         


        
5条回答
  •  悲&欢浪女
    2020-12-20 12:17

    You need to refer to KEY_STATE with struct KEY_STATE. In C++ you can leave the struct out, but not in plain C.

    Another solution is to do a type alias:

    typedef struct KEY_STATE KEY_STATE

    Now KEY_STATE means the same thing as struct KEY_STATE

提交回复
热议问题