What does extern inline do?
Unlike inline and static inline, extern inline is used in a specific context:
In pre-C99 compilers, particularly GCC, inline did not have defined semantics. However, GCC implemented inline as a hint to the compiler to inline the function if possible. Despite this suggestion, an out-of-line version of the function was always emitted and remained externally visible.
To address this limitation, GCC introduced extern inline and static inline.
GNU89:
-
inline: May be inlined, but an out-of-line version is always emitted and externally visible.
-
extern inline: Does not generate an out-of-line version, but may call one from another compilation unit.
-
static inline: Does not generate an externally visible out-of-line version, but may generate a file-static one.
C99 (or GNU99):
-
inline: Similar to GNU89 extern inline, no externally visible function is emitted.
-
extern inline: Similar to GNU89 inline, an externally visible code is emitted, allowing only one translation unit to use it.
-
static inline: Similar to GNU89 static inline, no external symbol or call to one is emitted.
C :
- Inline functions must be defined identically in all compilation units.
- There is no standard definition for extern inline or static inline, but some compilers provide these constructs based on the GNU89 model.
The above is the detailed content of What's the Difference Between `inline`, `extern inline`, and `static inline` in C and C ?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn