Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Inline function
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== gnu89 === gnu89 semantics of <code>inline</code> and <code>extern inline</code> are essentially the exact opposite of those in C99,<ref>{{Cite web|url=http://blahg.josefsipek.net/?p=529|title = Josef "Jeff" Sipek Β» GNU inline vs. C99 inline}}</ref> with the exception that gnu89 permits redefinition of an <code>extern inline</code> function as an unqualified function, while C99 <code>inline</code> does not.<ref name="gcc-5-porting">{{Cite web|url=https://gcc.gnu.org/gcc-5/porting_to.html|title = Porting to GCC 5 - GNU Project}}</ref> Thus, gnu89 <code>extern inline</code> without redefinition is like C99 <code>inline</code>, and gnu89 <code>inline</code> is like C99 <code>extern inline</code>; in other words, in gnu89, a function defined <code>inline</code> will always and a function defined <code>extern inline</code> will never emit an externally visible function. The rationale for this is that it matches variables, for which storage will never be reserved if defined as <code>extern</code> and always if defined without. The rationale for C99, in contrast, is that it would be [[principle of least astonishment|astonishing]] if using <code>inline</code> would have a side-effect—to always emit a non-inlined version of the function—that is contrary to what its name suggests. The remarks for C99 about the need to provide exactly one externally visible function instance for inlined functions and about the resulting problem with unreachable code apply mutatis mutandis to gnu89 as well. gcc up to and including version 4.2 used gnu89 <code>inline</code> semantics even when <code>-std=c99</code> was explicitly specified.<ref>{{Cite web|url=https://gcc.gnu.org/ml/gcc-patches/2007-02/msg00119.html|title = Ian Lance Taylor - Clean up extern inline}}</ref> With version 5,<ref name="gcc-5-porting"/> gcc switched from gnu89 to the gnu11 dialect, effectively enabling C99 <code>inline</code> semantics by default. To use gnu89 semantics instead, they have to be enabled explicitly, either with <code>-std=gnu89</code> or, to only affect inlining, <code>-fgnu89-inline</code>, or by adding the <code>gnu_inline</code> attribute to all <code>inline</code> declarations. To ensure C99 semantics, either <code>-std=c99</code>, <code>-std=c11</code>, <code>-std=gnu99</code> or <code>-std=gnu11</code> (without <code>-fgnu89-inline</code>) can be used.<ref name="gcc-inline"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)