Inline functions vs Preprocessor macros

后端 未结 14 2117
一个人的身影
一个人的身影 2020-11-22 12:37

How does an inline function differ from a preprocessor macro?

14条回答
  •  隐瞒了意图╮
    2020-11-22 13:38

    The key difference is type checking. The compiler will check whether what you pass as input values is of types that can be passed into the function. That's not true with preprocessor macros - they are expanded prior to any type checking and that can cause severe and hard to detect bugs.

    Here are several other less obvious points outlined.

提交回复
热议问题