Differences between struct in C and C++

后端 未结 5 2191
鱼传尺愫
鱼传尺愫 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:21

    In C, the name of the type is struct KEY_STATE.

    So you have to declare the second struct as

    typedef struct _DEVICE_EXTENSION
    {
        WDFDEVICE WdfDevice;
        struct KEY_STATE kState;
    } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
    

    If you do not want to write struct all the time, you can use a typedef declare KEY_STATE similar to DEVICE_EXTENSION:

    typedef struct _KEY_STATE
    {
        /* ... */
    } KEY_STATE;
    

提交回复
热议问题