$ gcc-10 --version
gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
$ cat test.c
struct A {
int a;
};
struct B {
int b;
struct A;
};
int main(void)
{
struct B c;
c.a = 0;
c.b = 1;
return 0;
}
$ gcc-10 test.c
test.c:7:13: warning: declaration does not declare anything
7 | struct A;
| ^
test.c: In function ‘main’:
test.c:13:6: error: ‘struct B’ has no member named ‘a’
13 | c.a = 0;
| ^
Adding -std=c17
does not make any difference. I checked (with the -v
option that cc1
gets called from the correct location (/usr/lib/gcc/x86_64-linux-gnu/10/cc1
). The source should compile, though. gcc 10.2.0 (used on Cygwin, for example), is perfectly able to deal with this code:
$ gcc --version
gcc (GCC) 10.2.0
$ gcc test.c
$
(no errors).
This is what was installed as "gcc-10":
cc-10-base/focal-updates,focal-security,now 10.3.0-1ubuntu1~20.04 amd64 [installed,automatic]
gcc-10/focal-updates,focal-security,now 10.3.0-1ubuntu1~20.04 amd64 [installed]
libgcc-10-dev/focal-updates,focal-security,now 10.3.0-1ubuntu1~20.04 amd64 [installed,automatic]
My system:
$ uname -a
Linux xxx 5.11.0-25-generic #27~20.04.1-Ubuntu SMP Tue Jul 13 17:41:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Any help will be greatly appreciated!
Thanks!