Hacker News new | ask | show | jobs
by MauranKilom 856 days ago
FYI on https://projects.blender.org/blender/blender/pulls/116089: `inline` first and foremost affects the One Definition Rule. Very briefly put: If you have a function defined (!) in a header (and call it in different .cc files), you will get linker errors unless you mark it as inline.

The effect on the actual inlining optimization could be anything between "none", "the compiler might weigh it differently purely due to linkage" and "it is actually taken as a hint", plus a similar set of considerations for link-time optimization. A much stronger inlining signal to the compiler (specifically for functions that are only used in the file they are defined in) is to define them in an anonymous namespace.

The original intent behind marking the function `inline` could reasonably have been an attempt at actually achieving inlining. A measurable benefit is not obvious (but also not impossible).