The problem I have is basically the same as \'greentype\' mentions at http://www.cplusplus.com/forum/beginner/12458/
I\'m sharing variables through namespaces and a
This has nothing really to do with namespaces, and all to do with the linkage, external or otherwise of the symbol i in your various examples. By default, global variables have extern linkage, while global const symbols have static linkage - this explains why it works when you make i const. To resolve your problem, one way is to declare i with extern linkage in the header file, then define it in only one of the implementation files, as shown below:
header:
extern int i;
a.c:
int i:
main.c:
int main()
{
i = 1; // or whatever
}
Note that I have removed the namespace for clarity - the end result is the same.