• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Compile error in GCC but not other compilers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compile error in GCC but not other compilers


  • Subject: Re: Compile error in GCC but not other compilers
  • From: Howard Hinnant <email@hidden>
  • Date: Tue, 16 May 2006 09:18:18 -0400

On May 15, 2006, at 5:57 PM, Duane Murphy wrote:

--- At Mon, 15 May 2006 17:15:55 -0400, Howard Hinnant wrote:

On May 15, 2006, at 3:08 PM, James W. Walker wrote:

One of my problems in porting from CodeWarrior to Xcode boils down
to the code below:

namespace
{
	class xxx
	{
		xxx();
	};
}

class yyy
{
	friend class xxx;
};

xxx::xxx()
{
}


Xcode says:

error: 'xxx' has not been declared
error: ISO C++ forbids declaration of 'xxx' with no type

CodeWarrior has no problem with this code, nor does the Comeau
online compiler test page.  So, is this a bug in GCC?

This looks like a bug to me. You could pop "::" unto xxx in the friend statement to workaround:

friend class ::xxx;

Unfortunately it isn't a very good workaround because it is now
illegal C++ code. :-(

I've hit this myself and scratched my head.

Can you explain why

friend class ::xxx;

is also illegal?

I thought I knew, but the more I looked into it, the more puzzled I became! ;-)


So I went to the committee on this one.  Here's the reply:

It is not possible to befriend a class in an unnamed namespace in C+ +03. So this behavior of gcc isn't a bug after all, and one can consider the:

friend class ::xxx;

an extension for now.

In C++0X it will be possible to befriend such a class, but the syntax will be slightly different:

friend xxx;

I'm not going to pretend to understand the name lookup rules in enough detail to explain the rationale here. But for the truly interested, the twisty tale starts here:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#138

This link will further link to other core issues, and to a paper (which introduces the friend xxx syntax). Sorry for the initial false direction.

-Howard

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Compile error in GCC but not other compilers (From: "James W. Walker" <email@hidden>)
 >Re: Compile error in GCC but not other compilers (From: Howard Hinnant <email@hidden>)
 >Re: Compile error in GCC but not other compilers (From: "Duane Murphy" <email@hidden>)

  • Prev by Date: Re: X-Code installation question
  • Next by Date: Re: X-Code installation question
  • Previous by thread: Re: Compile error in GCC but not other compilers
  • Next by thread: Re: Compile error in GCC but not other compilers
  • Index(es):
    • Date
    • Thread