I have the following souce about structure which compiled ok in gcc 4.4.6 :
struct st1 { char name[12]; int heartbeat ; double price ; int iFlag ; } ; struct st2 { struct st1 ; char pad[64 - sizeof(struct st1)] ; } __attribute__((aligned(64))) ; int main (void) { printf("length of struct st2=(%d)\n",sizeof(struct st2) ) ; } gcc -fms-extensions test1.c -o test1.exe ./test1.exe ===> length of struct st2=(64) I copy test1.c to test1.cpp and try to compile as :
g++ -fms-extensions test1.cpp -o test1.exe and then I got :
test1.cpp:23: error: invalid application of sizeof to incomplete type st2::st1
I know this error showes char pad[64 - sizeof(struct st1)] ; does not work in g++ , although it works in gcc , if I like this works in g++ , what can I do ?