By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,409 Members | 939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,409 IT Pros & Developers. It's quick & easy.

static friend function

P: n/a
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.
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Mike - EMAIL IGNORED" <m_*************@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
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.