libstdc++/94: Friends and Namespaces
joe_hesse@actcx.com
joe_hesse@actcx.com
Thu Oct 5 07:17:00 GMT 2000
>Number: 94
>Category: libstdc++
>Synopsis: Friends and Namespaces
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 05 07:17:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Joseph Hesse
>Release: gcc 2.95.??
>Organization:
>Environment:
RH Linux 6.2
>Description:
The following code with friends and namespaces doesn't compile with gcc -c test.cpp
The code seems ok to me and it does compile with no errors using the Comeau compiler.
>How-To-Repeat:
Just compile and observe the error output
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test.cpp"
Content-Disposition: inline; filename="test.cpp"
Does anyone know of an easy fix to make the following compile with g++.
I think that the code is correct but it fails to compile with g++.
The error messages are:
test.cpp:10: parse error before `('
test.cpp: In function `void f()':
test.cpp:7: `int N::XYZ::m_x' is private
test.cpp:17: within this context
The code compiles with the online Comeau compiler.
-----------------------------------------------
void f();
namespace N {
class XYZ {
private:
int m_x;
public:
XYZ(int u = 0) : m_x(u) {}
friend void ::f();
};
} // end of namespace N
void f() {
N::XYZ a(10);
a.m_x = 11;
}
-----------------------------------------------
More information about the Libstdc++-prs
mailing list