E
ehui928
/* test.c */
struct S
{
int a;
int b;
};
/*
The following 3 statements will cause compile error
when compiled under MinGW gcc3.4.2,the error message is:
"error: syntax error before '.' token"
*/
struct S ss;
ss.a = 1;
ss.b = 2;
int main()
{
printf("%d, %d\n", ss.a, ss.b);
return 0;
}
However, when I move the two struct assignment statements
into main function, as follows:
int main()
{
ss.a = 1;
ss.b = 2;
printf("%d, %d\n", ss.a, ss.b);
return 0;
}
it will be successfully compiled!
I have been greatly puzzled!!!
Can anyone explain the reason to me?
Thanks!
struct S
{
int a;
int b;
};
/*
The following 3 statements will cause compile error
when compiled under MinGW gcc3.4.2,the error message is:
"error: syntax error before '.' token"
*/
struct S ss;
ss.a = 1;
ss.b = 2;
int main()
{
printf("%d, %d\n", ss.a, ss.b);
return 0;
}
However, when I move the two struct assignment statements
into main function, as follows:
int main()
{
ss.a = 1;
ss.b = 2;
printf("%d, %d\n", ss.a, ss.b);
return 0;
}
it will be successfully compiled!
I have been greatly puzzled!!!
Can anyone explain the reason to me?
Thanks!