This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
namespace lookup
- From: "Ching, Jimen \(US SSA\)" <jimen dot ching at baesystems dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Thu, 24 May 2007 11:22:40 -1000
- Subject: namespace lookup
Hi,
I have the following code:
namespace X
{
namespace Y
{
namespace Z
{
struct A { typedef int int_t; };
struct Z { typedef int int_t; };
}
}
}
using namespace X::Y::Z;
int
main()
{
Z::A::int_t i = 0;
Z::Z::int_t j = 0;
return i == j;
}
I used the command:
g++ -ansi -Wall file.cpp
and I got the error:
file.cpp: In function 'int main()':
file.cpp:18: error: 'struct X::Y::Z::Z::A' has not been declared
file.cpp:18: error: expected `;' before 'i'
file.cpp:20: error: 'i' was not declared in this scope
Why did g++ look for struct A in struct Z instead of namespace Z?
It looked for struct Z in namespace Z.
Any help is greatly appreciated.
--jc
--
BAE Systems NS I&S
810 Richards Street, Ste. 124
Honolulu, HI 96813
Phone: 808 441-2563