Re: enum breaks the namespace
From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 01/17/05
- Next message: muchan: "Re: Bug in VC++ ? Rejects valid code."
- Previous message: Doug Harrison [MVP]: "Re: sizeof on arrays and pointers"
- In reply to: Paavo Helde: "enum breaks the namespace"
- Next in thread: Paavo Helde: "Re: enum breaks the namespace"
- Reply: Paavo Helde: "Re: enum breaks the namespace"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 17 Jan 2005 10:33:43 -0600
Paavo Helde wrote:
>MS Visual C++ 7.1 happily compiles the following:
>
>namespace First {
> class A {};
>}
>
>namespace Second {
> using namespace First;
> enum foo {bar};
>}
>
>int main() {
> A a; // Class A should not be visible!
>}
>
>
>Both Comeau online and gcc reject the code. When commenting out the "enum"
>line, also MSVC rejects the code. It seems like an enum definition exports
>the "using namespace" directive out of the second namespace!
>
>Is this a known bug? And is there some workaround? I would not like to leak
>names all over the place, but in the same time I would like to make the
>First library automatically accessible to the clients who have the "using
>namespace Second;" directive in their code.
This appears to be fixed in the Whidbey beta. For VC7.1, I don't know of any
workaround, but then I tend not to use using-directives as above.
-- Doug Harrison Microsoft MVP - Visual C++
- Next message: muchan: "Re: Bug in VC++ ? Rejects valid code."
- Previous message: Doug Harrison [MVP]: "Re: sizeof on arrays and pointers"
- In reply to: Paavo Helde: "enum breaks the namespace"
- Next in thread: Paavo Helde: "Re: enum breaks the namespace"
- Reply: Paavo Helde: "Re: enum breaks the namespace"
- Messages sorted by: [ date ] [ thread ]