Reputation: 395
In my project, I have an existing file:
namespace Cpld_A
{
const int XXX;
}
And ABC_Existing.cc uses the variable XXX doing 'using namespace Cpld'.
I created a new file:
namespace Cpld_B
{
const int XXX;
}
And I am trying to use it in XYZ_New.cc. When I compile, I get error saying ambiguous declaration of variable XXX between Cpld_A and Cpld_B. There is no relation between ABC_Existing and XYZ_New. And ABC_Existing.h is not included (directly or indirectly) in XYZ_New.h/cc. But, all these files are in the same folder and build together.
How can this problem happen, and how do I resolve this ? Appreciate your help !!!
Upvotes: 0
Views: 53
Reputation: 206508
Most likely, the ambiguity is because both the same namespaces and hence the symbol names within are imported in to your current namespace by some indirect obscure way.
A simple way to resolve the ambiguity is by using the fully qualified names of the symbols, when referring to them:
Cpld_A::XXX
Cpld_B::XXX
Upvotes: 2