delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/04/23/11:00:49

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Michael Beck <beck AT ipd DOT info DOT uni-karlsruhe DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Inline functions question
Date: Fri, 23 Apr 2004 16:45:41 +0200
Organization: University of Karlsruhe, Germany
Lines: 34
Message-ID: <c6ba6l$kfk$1@news2.rz.uni-karlsruhe.de>
References: <c6b824$2ks9$1 AT alpha2 DOT radio-msu DOT net>
NNTP-Posting-Host: i44pc33.info.uni-karlsruhe.de
Mime-Version: 1.0
X-Trace: news2.rz.uni-karlsruhe.de 1082731541 20980 172.22.85.161 (23 Apr 2004 14:45:41 GMT)
X-Complaints-To: usenet AT rz DOT uni-karlsruhe DOT de
NNTP-Posting-Date: Fri, 23 Apr 2004 14:45:41 +0000 (UTC)
User-Agent: KNode/0.7.1
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Anthony wrote:

> Why does this code
[..]
> inline void A::f2(const char *str)
> {
>     std::cout << "\n __func__ = " << __func__
>             << "\n __PRETTY_FUNCTION__ = " << __PRETTY_FUNCTION__
>             << "\n Caller = " << str;
> }
> 
> void A::f1()
> {
>     std::cout << "\n Now f1() will call f2().";
>     f2(__func__);
> }
[..]
> produces this:
> 
> Now f1() will call f2().
> __func__ = f2        <---- I expected f1
> __PRETTY_FUNCTION__ = void A::f2(const char*)        <---- I expected
> A::f2(...)
> Caller = f1
> 
> The f2() is supposed to be implanted in f1(), no?

Yes, but inlining is done in the optimization phase, while __func__
is typically resolved be the frontend. So, BEFORE f2 is "implanted",
__func__ is already resolved into the constant "f2".

best regards,
-- 
Michael Beck            beck AT ipd DOT info DOT uni-karlsruhe DOT de

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019