X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Michael Beck 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: References: NNTP-Posting-Host: i44pc33.info.uni-karlsruhe.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit 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