GCC compile problem:struct A have a member variable which is just a struct type name?
my code is as follow:
typedef struct a { uint32_t ulMsgType; } a; typedef struct b { a; uint32_t ulIfCount; } b; b *pb; if my code use pb->ulMsgType, then GCC (4.1.1 20061011) cannot compile it ,it will output an error that struct b doesn't have member "ulMsgType". But if I run the code in a cross-compile environment, just like hardhat3.0, using xscale_be-gcc(3.2.1 20020930), the code can be compiled successfully. So my questions is what should i do to make it compile successfully? Whether I could add some options for GCC (4.1.1 20061011) to fix the problem, if so, what options should I add? ------------------------- OS: 2.6.18-1.2798.fc6 |
Hello,
Try changing pb->ulMsgType to pb->a.ulMsgType |
I have fix the problem,
GCC need add a option "-fms-extensions". |
Let me point out that although it “works”, this is not standards-compliant behavior. In fact, the correct thing to do is to name your field so you can refer to it directly.
|
All times are GMT -5. The time now is 04:26 AM. |