D
Dan Elliott
Hello,
Converting from a working C program to C++, I run into the following error:
I have a header: (header.h)
namespace shared{
...
struct X{
...
};
extern X a;
}
In a .cc file I have:
using namespace shared;
X a;
main(){
....
}
The compiler tells me that a is ambiguous.
If I modify header.h to have extern X a outside of the "shared" namespace or
modify the .cc file to look like:
shared::X a;
main(){
....
}
There are no complaints.
However, there are no assurances that the second solution (modification of
the .cc file) is actually declaring my global variable. It may be simply
creating another file-level variable thinking shared::X is supposed to
resolve to the struct X in the same namespace. How should I tell the
compiler I am trying to declare the global variable "a" in my .cc file?
By the way, I am using VisualAge C++ Professional / C for AIX Compiler,
Version 5.
Thank you for your time.
- dan elliott
Converting from a working C program to C++, I run into the following error:
I have a header: (header.h)
namespace shared{
...
struct X{
...
};
extern X a;
}
In a .cc file I have:
using namespace shared;
X a;
main(){
....
}
The compiler tells me that a is ambiguous.
If I modify header.h to have extern X a outside of the "shared" namespace or
modify the .cc file to look like:
shared::X a;
main(){
....
}
There are no complaints.
However, there are no assurances that the second solution (modification of
the .cc file) is actually declaring my global variable. It may be simply
creating another file-level variable thinking shared::X is supposed to
resolve to the struct X in the same namespace. How should I tell the
compiler I am trying to declare the global variable "a" in my .cc file?
By the way, I am using VisualAge C++ Professional / C for AIX Compiler,
Version 5.
Thank you for your time.
- dan elliott