I try to compile this code with Windows 8 SDK :
typedef struct {
enum { red, blue, green } eColor;
/* other params here */
} StMyStruct;
void Myfunction(StMyStruct *pst)
{
if (pst->eColor==StMyStruct.red) {
/* some code here */
}
}
But I get this error on line if pst->eColor==StMyStruct.red :
error C2275: ‘StMyStruct’ : illegal use of this type as an expression
Any idea how to fix it ?
I compile this code successfully with Windows SDK 7, error happen only with Windows 8 SDK.
Try
StMyStruct::red.Also, you don’t need the
typedef, that is mainly used when developing C — in C++, you can refer to a struct and class name directly.