static friend function



 DEVELOP > c-Plus-Plus > static friend function

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Mike - EMAIL IGNORED"
Date: 26 Nov 2003 09:37:04 PM
Object: static friend function
Are static friend functions allowed? I tried this
today with gcc-3.2 without success. The function
was not a class member. The friend statement was
interpreted as meaning "extern", and this was
reported incompatible with a previous static
declaration.
Chapter and verse would also be helpful. I looked
around but didn't find anything.
Thanks in advance,
Mike.
.

User: "Victor Bazarov"

Title: Re: static friend function 26 Nov 2003 10:32:51 PM
"Mike - EMAIL IGNORED" <m_d_berger_1900@yahoo.com> wrote...

Are static friend functions allowed? I tried this
today with gcc-3.2 without success. The function
was not a class member. The friend statement was
interpreted as meaning "extern", and this was
reported incompatible with a previous static
declaration.

Chapter and verse would also be helpful. I looked
around but didn't find anything.

Apparently gcc-3.2 is buggy. The Standard, 11.4/3
_clearly_ says: "A function first declared in a friend
declaration has external linkage (3.5). Otherwise, the
function retains its previous linkage (7.1.1)." So,
if the function has been declared static before being
declared 'friend', it must be accepted.
Keep in mind, though, that "No storage-class-specifier
shall appear in the decl-specifier-seq of a friend
declaration." (11.4/6)
HTH
Next time post the code.
Victor
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER