What's the difference in practice between inline and #define?

后端 未结 5 1690
遇见更好的自我
遇见更好的自我 2021-02-13 06:47

As the title says; what\'s the difference in practice between the inline keyword and the #define preprocessor directive?

5条回答
  •  迷失自我
    2021-02-13 07:36

    Macros (created with #define) are always replaced as written, and can have double-evaluation problems.

    inline on the other hand, is purely advisory - the compiler is free to ignore it. Under the C99 standard, an inline function can also have external linkage, creating a function definition which can be linked against.

提交回复
热议问题