Your assumption is correct: the second declaration a has an external connection. However, you get an error because your code violates the restriction in ยง6.7:
3 If the identifier has no connection, there should be no more than one declaration of the identifier (in a pointer or type specifier) โโwith the same scope and in the same namespace, except for tags as specified in clause 6.7.2.3.
That is, once you have declared a to have no connection, you cannot reuse it in the same area.
A valid example of this rule is:
int a = 10; void foo(void) { int a = 5; printf("%d\n", a); { extern int a; printf("%d\n", a); } }
source share