[Copy to clipboard] [ - ]CODE:#include <stdio.h>
inline void test(void)
{
}
int main()
{
return 0;
}
gcc -std=c99 -o inline inline.c // 為什麼我加入 -std=c99 會出現下面警告訊息, inline 不是C 99 嗎?
inline.c:4: warning: C99 inline functions are not supported; using GNU89
inline.c:4: warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
謝謝
static inline
参考一下
http://www.greenend.org.uk/rjk/2003/03/inline.html
一下是c99的
6.7.4 Function specifiers
Syntax
1 function-specifier:
inline
Constraints
2 Function specifiers shall be used smilieid="44" border="0" alt="" /> The extent to which such suggestions are effective is
implementation-defined.119)
6 Any function with internal linkage can be an inline function. For a function with external
linkage, the following restrictions apply: If a function is declared with an inline
112 Language §6.7.4
WG14/N1124 Committee Draft — May 6, 2005 ISO/IEC 9899:TC2
function specifier, then it shall also be defined in the same translation unit. If all of the
file scope declarations for a function in a translation unit include the inline function
specifier without extern, then the definition in that translation unit is an inline
definition. An inline definition does not provide an external definition for the function,
and does not forbid an external definition in another translation unit. An inline definition
provides an alternative to an external definition, which a translator may use to implement
any call to the function in the same translation unit. It is unspecified whether a call to the
function uses the inline definition or the external definition.120)
EXAMPLE The declaration of an inline function with external linkage can result in either an external
7
definition, or a definition available for use smilieid="44" border="0" alt="" /> By using, for example, an alternative to the usual function call mechanism, such as ‘‘inline
会员注册
会员登录
个人空间