I see flow c language code in the windows driver kit(WDK) sample:
typedef struct _COMMON_DEVICE_DATA
{
PDEVICE_OBJECT Self;
BOOLEAN IsFDO;
......................
} COMMON_DEVICE_DATA, *PCOMMON_DEVICE_DATA;
typedef struct _PDO_DEVICE_DATA
{
COMMON_DEVICE_DATA;
PDEVICE_OBJECT ParentFdo;
.................
} PDO_DEVICE_DATA, *PPDO_DEVICE_DATA;
But when I want to test the smillar code , it build error.
test.c:14:6: error: ‘AA’ has no member named ‘flag’
a.flag = 1;
Tesing code as fllow:
typedef struct __COMMON_DATA{
int flag;
}COMMON_DATA;
typedef struct __AA{
COMMON_DATA;
int x;
int y;
}AA;
int main(int argc, char *argv[])
{
AA a;
a.flag = 1;
return 0;
}
All seem same as the window sample code, But where is it wrong?
there is no member named flag because AA has no member named flag
You should access actual flag in the COMMON_DATA struct not in AA struct