Re: Anonymous namespace clashes
Re: Anonymous namespace clashes
- Subject: Re: Anonymous namespace clashes
- From: Howard Hinnant <email@hidden>
- Date: Mon, 29 Jan 2007 16:09:13 -0500
On Jan 26, 2007, at 4:39 AM, Paul Walmsley wrote:
I've just experienced a problem with anonymous namespaces. I have
two source files, each with a couple of private functions and
variables in an anonymous namespace. Some of these happen to have
the same name. I get a 'multiply-defined symbol' error on linking.
Surely - if my understanding is correct - this shouldn't happen
since anonymous namespaces are local to the translation unit?
I'm trying to replicate this symptom and so far have not been able
to. In one file I have:
#include <iostream>
void foo();
namespace
{
int x = 1;
void bar(int& y)
{
std::cout << y << '\n';
}
}
int main()
{
bar(x);
foo();
}
In another file I have:
#include <iostream>
namespace
{
int x = 2;
void bar(int& y)
{
std::cout << y << '\n';
}
}
void foo()
{
bar(x);
}
This program compiles and prints out:
1
2
(as expected).
Can you perhaps reduce your problem to a small test case and either
post it here or file a bug?
Thanks,
Howard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden