This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]