In the process of doing Windows Server migration to Linux, there was a problem with the compilation class
The following structure is defined in the code
struct msginfo{ Union { struct { OBJID idtype; UINT unexp; }; struct { OBJID idtype; UCHAR Ucresult;} ;} }
Under Windows Secure compilation passed, under the Linux GCC cannot be compiled.
This is because the anonymous struct is used in the code, the anonymous struct can be accessed directly under Windows, and the code is heavily used such as M_pinfo->idtype,
In the case of GCC, the lack of a name for the structure of the experience caused confusion.
On this issue, you can look at this discussion string
Http://stackoverflow.com/questions/1972003/how-to-compile-c-code-with-anonymous-structs-unions
You can see that if you add some compile parameters, you can ensure that the compilation is passed,
And the new C11 and c++11 are allowed to do this.
And I'm here for the transplant, for the time being the old scheme, because the GCC version is low, give each struct a name
struct msginfo{ Union { struct { OBJID idtype; UINT unexp; } Expinfo; struct { OBJID idtype; UCHAR ucresult; } Learninfo;} }
That's all.
You can then use M_pinfo->learninfo.idtype to access the
Anonymous struct problem with porting code to Linux