Does GCC inline C++ functions without the 'inline' keyword?

前端 未结 4 1032
不知归路
不知归路 2020-12-03 04:45

Does GCC, when compiling C++ code, ever try to optimize for speed by choosing to inline functions that are not marked with the inline keyword?

4条回答
  •  借酒劲吻你
    2020-12-03 05:02

    Yes, it does, although it will also generate a non-inlined function body for non-static non-inline functions as this is needed for calls from other translation units.

    For inline functions, it is an error to fail to provide a function body if the function is used in any particular translation unit so this isn't a problem.

提交回复
热议问题