Search code examples
c++inlinekeyword

inline vs __inline vs __inline__ vs __forceinline?


What are the differences between these four inline (key)words?

inline, __inline, __inline__, __forceinline.


Solution

  • inline is the keyword, in C++ and C99.

    __inline is a vendor-specific keyword (e.g. MSVC) for inline function in C, since C89 doesn't have it.

    __inline__ is similar to __inline but is from another set of compilers.

    __forceinline is another vendor-specific (mainly MSVC) keyword, which will apply more force to inline the function than the __inline hint (e.g. inline even if it result in worse code).

    There's also __attribute__((always_inline)) in GCC and clang.