|
| | Subject: | Re: Friend functions | | Group: | Gcc-help | | From: | Ian Lance Taylor | | Date: | 20 Apr 2007 |
David Sveningsson <ext> writes:
> Hi, the following code compiles with GCC 4.0.1 and VC2005 but not GCC 4.1.1.
>
> class Foo {
> friend void friend_func();
> public:
> virtual void func();
> };
>
> void Foo::func(){
> friend_func();
> }
>
> It fails with '"friend_func" was not declared in this scope'. By also
> declaring friend_func outside of class Foo it compiles on all
> platforms but what I wonder is why this changed from GCC 4.0.x and GCC
> 4.1.x. I guess it's intentionally and not a bug.
See the description of the -ffriend-injection option.
Ian
|