This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ language lawyer question


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]