C99/GNU99对inline关键字的处理不同于C89
C99 inline semantics are often misunderstood. The inline specifier serves two purposes:
First, as a compiler hint in case of
static inline
andextern inline
declarations. Semantics remain unchanged if you remove the specifier.
Second, in case of raw inline (ie without
static
orextern
) to provide an inline definition as an alternative to an external one, which has to be present in a different translation unit. Not providing the external one is undefined behaviour, which will normally manifest as linking failure.
带有static
和extern
的情况下,
1
2static inline === static
extern inline === extern
否则,和 1
inline === extern
Ref: http://stackoverflow.com/a/16254679