The following code:
#include
inline int myfunc (int x) {
return x+3;
}
int main () {
printf(\"%d\", myfunc(2));
return 0;
}
This is the gnu_inline
hiccup. Use -std=gnu99 -fgnu89-inline
.
For more information see Function Attributes (item gnu_inline
).
The relevant passage:
In C, if the function is neither extern nor static, then the function is compiled as a standalone function, as well as being inlined where possible.
This is how GCC traditionally handled functions declared inline. Since ISO C99 specifies a different semantics for inline, this function attribute is provided as a transition measure and as a useful feature in its own right. This attribute is available in GCC 4.1.3 and later. It is available if either of the preprocessor macros GNUC_GNU_INLINE or GNUC_STDC_INLINE are defined. See An Inline Function is As Fast As a Macro.