C: inline without forcing?

Segher Boessenkool segher@kernel.crashing.org
Thu Jun 3 05:12:25 GMT 2021


On Wed, Jun 02, 2021 at 10:42:06PM -0400, Danielle Church wrote:
> On Wed, Jun 2, 2021, 18:30 Segher Boessenkool <segher@kernel.crashing.org>
> wrote:
> 
> > On Wed, Jun 02, 2021 at 12:22:58PM -0400, Danielle Church wrote:
> > > On Wed, Jun 2, 2021 at 11:54 AM Segher Boessenkool
> > > <segher@kernel.crashing.org> wrote:
> > > > > Is there no way to get the code-emit behavior (inline the
> > > > > function or emit a TU-external reference, don't emit standalone
> > > > > definition) without the optimizer changes (more likely to inline the
> > > > > function, even if it's a bad idea)?
> > > >
> > > > extern attribute((gnu_inline))
> > >
> > > Does ``extern inline attribute((gnu_inline))'' behave appreciably
> > > differently than C99's bare ``inline''? They seem to have the same
> > > effect from the documentation, though with reversed semantics for the
> > > presence vs absence of the extern keyword.
> >
> > Neither GNU inline nor standard C inline is inclusive of the other.  A
> > gnu_inline extern inline is never emitted as a standalone function.
> >
> 
> Can you explain to me how that's different from C99 inline? I'm afraid I
> don't understand, since a C99 declaration like
> 
> inline void foo() {
>  ...
> }
> 
> won't emit a standalone function either, no?

It does if you first declared foo() without inline:

int f(void);
inline int f(void) { return 42; }


Segher


More information about the Gcc-help mailing list