Link-time optimization and inline

前端 未结 6 876
情话喂你
情话喂你 2020-12-08 16:12

In my experience, there\'s lot of code that explicitly uses inline functions, which comes at a tradeoff:

  1. The code becomes less succinct and somewhat less maint
6条回答
  •  [愿得一人]
    2020-12-08 17:03

    If link time optimization were as fast as compile time optimization, then it would obviate the need for compiler hints. Unfortunately, it is generally not faster than compile time optimization, so it's a tradeoff between overall build speed and the overall quality of optimizations for that build.

    Also, you still need to use inline when defining functions in headers. Otherwise, you will get linker errors for multiple definitions of those functions if they are used in multiple translation units.

提交回复
热议问题