This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: inline funtcion of base class
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Hatt Tom <net dot study dot sea at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 20 Aug 2013 10:30:06 +0100
- Subject: Re: inline funtcion of base class
- References: <CAHvbk5Mj2VXB5Sa=9+wBNYiFKSL+7wxU=_H4YpE+Ydkk0bAU9g at mail dot gmail dot com> <CAH6eHdR68pCMOQ0FTR6zZY-AAph9cLoa-ifak4_V4d15bF3GmA at mail dot gmail dot com> <CAHvbk5N8U-e_-3jf7n1xiorFymJh6exwUoQdqq=W8J_3CE_xyg at mail dot gmail dot com>
On 20 August 2013 09:53, Hatt Tom wrote:
> Thanks for reply !
>
>
> I look into the disassembly instructions ,it show me that the call
> procedure of B::func() own its stack frame ,and its first
> instruction is push %ebp .
>
> so It is not dealed as a inline .
The compiler is not required to inline functions even if they're
declared as inline. If you don't enable optimisations when compiling
there will be no function inlining. Even with optimisations the
compiler might decide inlining the function would make it slower.
If you want to force the optimisers to inline it you can use the GNU
attribute always_inline.