Re: Friend functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Sveningsson <ext@xxxxxxxxxxx> 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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux