Consider the following code:
#include <stdio.h>
namespace EnclosingNmspc
{
namespace Nmspc
{
extern int a;//This a and the a defined above denote the same entity
int a=5;
}
}
extern int a;
int main()
{
printf("%d\n",a);
}
There is the quote from 3.5/2:
When a name has external linkage , the entity it denotes can be referred to by names from scopes of other translation units or from other scopes of the same translation unit.
I dont understand why this rule doesn't work in my case? I have undefined reference
linker error.