C99/GNU99对inline关键字的处理不同于C89

来源:互联网 发布:林弯弯的淘宝店叫什么 编辑:程序博客网 时间:2024/06/05 10:13

C99 inline semantics are often misunderstood. The inline specifier serves two purposes:

First, as a compiler hint in case of static inline and extern inline declarations. Semantics remain unchanged if you remove the specifier.

Second, in case of raw inline (ie without static or extern) 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.

带有staticextern的情况下,

static inline === staticextern inline === extern

否则,和

inline === extern

Ref: http://stackoverflow.com/a/16254679

0 0
原创粉丝点击