Inline vs __inline vs __inline__ vs __forceinline?

What are the differences between these four inline (keywords) keywords?

inline , __inline , __inline__ , __forceinline .

+52
c ++ keyword inline
May 04 '10 at 12:24
source share
3 answers

inline is a keyword in C ++ and C99.

__inline is a __inline - __inline keyword (such as MSVC ) for an inline function in C since C89 does not have one.

__inline__ is similar to __inline , but from a different set of compilers.

__forceinline is another __forceinline - __forceinline keyword (mainly MSVC) that will use more force to enable a feature than the __inline hint (for example, built-in, even if it leads to code degradation).

There is also __attribute__((always_inline)) in GCC and clang.

+71
May 04 '10 at
source share

__inline , __inline__ and __forceinline are implementation specific. Due to the double underscore, all identifiers reserved for implementation, therefore, should not conflict with identifiers used in applications.

inline is the only C ++ keyword.

+18
May 04 '10 at 12:28
source share

For the Visual Studio compiler, this means:

  • inline - a suggestion to the compiler to embed your code

  • __ forceinline - overrides inline compiler optimization and generates inline code

For more details see http://msdn.microsoft.com/en-us/library/z8y1yy88%28VS.71%29.aspx

+8
May 4 '10 at 12:32
source share



All Articles