When should I use __forceinline instead of inline?

前端 未结 12 1386
旧巷少年郎
旧巷少年郎 2021-01-01 09:34

Visual Studio includes support for __forceinline. The Microsoft Visual Studio 2005 documentation states:

The __forceinline keyword overrides the co

12条回答
  •  北海茫月
    2021-01-01 09:51

    Actually, even with the __forceinline keyword. Visual C++ sometimes chooses not to inline the code. (Source: Resulting assembly source code.)

    Always look at the resulting assembly code where speed is of importance (such as tight inner loops needed to be run on each frame).

    Sometimes using #define instead of inline will do the trick. (of course you loose a lot of checking by using #define, so use it only when and where it really matters).

提交回复
热议问题