Sample code:
void f(void)
{
int x;
int x;
}
Invocations:
$ gcc t0.c -std=c11 -pedantic -Wall -Wextra
t0.c: In function 'f':
t0.c:4:9: error: redeclaration of 'x' with no linkage
4 | int x;
| ^
t0.c:3:9: note: previous declaration of 'x' with type 'int'
3 | int x;
| ^
$ clang t0.c -std=c11 -pedantic -Wall -Wextra
t0.c:4:9: error: redefinition of 'x'
int x;
^
t0.c:3:9: note: previous definition is here
int x;
^
$ cl t0.c /std:c11 /Za
t0.c(4): error C2086: 'int x': redefinition
t0.c(3): note: see declaration of 'x'
As I understand int x;
is a definition of an identifier x
. Is that correct?