J
Jonathan Pryor
I'm in need of a sanity check: is the following code valid C++?
namespace foo {
class NamespaceClass {
};
}
using namespace foo;
class Bug_GlobalFriendDeclaresNamespaceClass {
friend class NamespaceClass;
};
class UseNamespaceClass {
public:
NamespaceClass* GetFoo ();
friend class NamespaceClass;
};
int main ()
{
}
This compiles for me under GCC 3.3.3 (Linux), GCC 3.4.4 (cygwin), GCC
4.0.0 20041026 (Apple build 4061 on a PPC Mac).
This doesn't compile for me under GCC 4.0.1 (Apple build 5250 on an
intel mac). I suspect a compiler bug, but I'd like to make sure the
code itself isn't faulty before blaming the compiler. GCC complains
with the error:
friend.cpp:14: error: ISO C++ forbids declaration of 'NamespaceClass'
with no type
friend.cpp:14: error: expected ';' before '*' token
It seems that the friend declaration within
Bug_GlobalFriendDeclaresNamespaceClass introduces a new NamespaceClass
declaration (presumably at the global scope) which screws up the
UseNamespaceClass use of NamespaceClass.
Any ideas?
Thanks,
- Jon
namespace foo {
class NamespaceClass {
};
}
using namespace foo;
class Bug_GlobalFriendDeclaresNamespaceClass {
friend class NamespaceClass;
};
class UseNamespaceClass {
public:
NamespaceClass* GetFoo ();
friend class NamespaceClass;
};
int main ()
{
}
This compiles for me under GCC 3.3.3 (Linux), GCC 3.4.4 (cygwin), GCC
4.0.0 20041026 (Apple build 4061 on a PPC Mac).
This doesn't compile for me under GCC 4.0.1 (Apple build 5250 on an
intel mac). I suspect a compiler bug, but I'd like to make sure the
code itself isn't faulty before blaming the compiler. GCC complains
with the error:
friend.cpp:14: error: ISO C++ forbids declaration of 'NamespaceClass'
with no type
friend.cpp:14: error: expected ';' before '*' token
It seems that the friend declaration within
Bug_GlobalFriendDeclaresNamespaceClass introduces a new NamespaceClass
declaration (presumably at the global scope) which screws up the
UseNamespaceClass use of NamespaceClass.
Any ideas?
Thanks,
- Jon