I've encountered with declaration definition :
A declaration is a definition unless it declares a function without specifying the function’s body
#include <stdio.h>
void foo()
{
printf("foo\n");
}
int main()
{
void foo();
foo();
}
In the 3.3 said
The scope of a declaration is the same as its potential scope unless the potential scope contains another declaration of the same name.
Question 1. Does it mean that in my case when we redeclare foo into the main function the redeclared foo actually denote the entity different from entity denoted by foo declared into the global scope?
Question 2. Why unqualified name lookup resolution gives an entity denoted by "global" foo?
UPD: If we consider the following
#include <stdio.h>
int a=42;
int main()
{
int a;
printf("%d\n",a); //Garbage
}
Then there a
inside the function scope doesn't denoted to the global a
. How to explain it?