Created attachment 32419 [details] Source file to reproduce the issue If you compile the following piece of code using g++ (4.7.2): " class class1; namespace ns1 { class class2; class class3; } ns1::class3 *func(ns1::class2 * cfg, const class1 * def); namespace ns1 { class class4 { #ifdef WORKAROUND friend ns1::class3 *(::func)(ns1::class2 * cfg, const class1 * def); #else friend class3 *(::func)(class2 * cfg, const class1 * def); #endif }; } " (also attached) you get the following: $ g++ -c test.cpp test.cpp:17:25: error: ‘func’ is neither function nor member function; cannot be declared friend test.cpp:17:23: error: expected ‘;’ at end of member declaration test.cpp:17:32: error: expected ‘)’ before ‘*’ token Now, if you explicitely add the namespaces as they appear in the initial declaration (add -DWORKAROUND), the compilation succeeds.
This looks like a dup *** This bug has been marked as a duplicate of bug 57376 ***