static friend function

  • Thread starter Mike - EMAIL IGNORED
  • Start date
M

Mike - EMAIL IGNORED

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.
 
V

Victor Bazarov

Mike - EMAIL IGNORED said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,383
Latest member
EzraGiffor

Latest Threads

Top