[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Re: groff 1.19.1 compilation with xlC och AIX
From: |
Bruno Hertz |
Subject: |
Re: [Groff] Re: groff 1.19.1 compilation with xlC och AIX |
Date: |
26 May 2004 21:57:37 +0200 |
On Wed, 2004-05-26 at 15:39, Werner LEMBERG wrote:
> Code like this:
>
> void end_diversions();
>
> class diversion {
> friend void do_divert(int append, int boxing);
> friend void end_diversions();
>
> produces a warning about declaring `end_diversions' twice. Is
> somebody on the list who knows the C++ standard well enough to decide
> whether this is a feature of g++ or whether this really conforms to
> ANSI C++?
>
Hmm. Don't know about your g++ versions, but with my Redhat 9 g++ 3.2.2
this does not produce a warning, which to the best of my knowledge is
the correct behavior.
More specifically, according to Stroustrup TC++PL 3rd Ed. the order is
important since a friend declaration does not introduce a name into the
enclosing scope. I.e. in code
class diversion {
friend void do_divert(int append, int boxing);
friend void end_diversions();
};
void end_diversions();
end_diversions does not become a friend to diversion. Not sure however
wether it's actually an error.
This view seems to be confirmed by the standard ISO/IEC 14482:
3.3.1p6
[Note: friend declarations refer to functions or classes that are
members of the nearest enclosing namespace, but they do not introduce
new names into that namespace (7.3.1.2). ... ]
Your code on the other hand
void end_diversions();
class diversion {
friend void do_divert(int append, int boxing);
friend void end_diversions();
};
should be perfectly correct.
Bruno
PS: Sorry Werner for mailing to you directly. Unfortunately 'reply'
doesn't do the right thing on this list, which I sometimes forget.