inline
Alejandro Colomar
alx@kernel.org
Tue Nov 11 21:52:23 GMT 2025
Hi Bruno,
On Tue, Nov 11, 2025 at 07:53:01PM +0100, Bruno Haible wrote:
> Alejandro Colomar wrote:
> > > > - inline
> > >
> > > Beware! Only 'static inline' is reasonably portable to C99.
> > > The semantics of 'extern inline' changed in gcc 4.2 / 4.3 / 4.4.
> >
> > Hmmmm, C99's extern inline is one I'm very interested in. Would you
> > mind pointing at the changes in 4.x you're referring to? I'd like to
> > learn about them.
>
> In gcc < 4.3, 'inline' without 'static' has the semantics described in [1].
> In gcc >= 4.3, 'inline' without 'static' has the semantics described in [2],
> which is consistent with ISO C 99. The old GNU 'inline' semantics can be
> obtained through __attribute__ ((__gnu_inline__)).
Ahhh, yeah, the switch from GNU inline to C99 inline. I'm aware of
that. I thought you meant that it changed more than once.
If glibc started using C99 inline, maybe it could be done like this:
#if defined(__GNUC_GNU_INLINE__)
#define __inline extern inline
#endif
And then use C99 inline everywhere. That is, use '__inline' in headers,
and 'extern inline' in source files.
Have a lovely night!
Alex
> Gnulib has this summary:
>
> GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
> inline semantics, unless -fgnu89-inline is used. It defines a macro
> __GNUC_STDC_INLINE__ to indicate this situation or a macro
> __GNUC_GNU_INLINE__ to indicate the opposite situation.
> GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
> semantics but warns, unless -fgnu89-inline is used:
> warning: C99 inline functions are not supported; using GNU89
> warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
> It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.
>
> Btw, there is a typo in misc/sys/cdefs.h; fix attached.
>
> [1] https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Inline.html
> [2] https://gcc.gnu.org/onlinedocs/gcc-4.3.6/gcc/Inline.html
--
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20251111/34af1d01/attachment-0001.sig>
More information about the Libc-alpha
mailing list