inline
Bruno Haible
bruno@clisp.org
Tue Nov 11 18:53:01 GMT 2025
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__)).
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-typo.diff
Type: text/x-patch
Size: 1162 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20251111/b3fb13a8/attachment-0001.bin>
More information about the Libc-alpha
mailing list