When is “inline” ineffective? (in C)

前端 未结 12 653
鱼传尺愫
鱼传尺愫 2020-12-09 10:56

Some people love using inline keyword in C, and put big functions in headers. When do you consider this to be ineffective? I consider it s

12条回答
  •  星月不相逢
    2020-12-09 11:53

    Another reason why you shouldn't use inline for large functions, is in the case of libraries. Every time you change the inline functions, you might loose ABI compatibility because the application compiled against an older header, has still inlined the old version of the function. If inline functions are used as a typesafe macro, chances are great that the function never needs to be changed in the life cycle of the library. But for big functions this is hard to guarantee.

    Of course, this argument only applies if the function is part of your public API.

提交回复
热议问题