This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ language lawyer question
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: gcc at gcc dot gnu dot org
- Date: 10 Mar 2004 08:55:36 +0100
- Subject: Re: C++ language lawyer question
- Organization: Integrable Solutions
- References: <20040310044725.GA7380@spuckler.il.thewrittenword.com>
Albert Chin <gcc@lists.thewrittenword.com> writes:
| In the process of compiling KDE 3.2 on IRIX 6.5 and Tru64 UNIX 5.1
| with the respective vendor C++ compilers, I ran into a namespace
| issue. Consider the following:
This is really a question for comp.lang.c++.moderated or comp.std.c++.
| $ cat a.h
| class KMAcctImap;
|
| namespace KIO {
| class Job {
| public:
| int b;
| };
| }
|
| namespace KMail {
| class ImapJob {
| friend class KMAcctImap;
In a friend declaration like that, if the thingy being given a
friendship is unqualified, then either there is a matching declaration
in the enclosing scope or it is considered invisibly declared in the
innermost enclosing namespace. So KMAcctImap is invisibly declared in
KMail::. So despite appearance, you're not saying that ::KMAcctImap is
friend of KMail::ImapJob. If a compiler does not understand that,
then it has a bug in that area (that is the only point that makes your
posting relevant here because GCC does not get it right :-().
[...]
| I can cause a successful compile by changing:
| namespace KMail {
| class ImapJob {
| friend class KMAcctImap;
| to:
| namespace KMail {
| class ImapJob {
| friend class ::KMAcctImap;
| ^^
|
| So, who is right and why?
See above.
-- Gaby