What does 'inline' mean?

Patrick Schluter Patrick.Schluter at bbox.fr
Fri Jun 12 13:57:46 UTC 2020


On Friday, 12 June 2020 at 13:27:23 UTC, Andrei Alexandrescu 
wrote:
> On 6/8/20 10:09 AM, Manu wrote:
>> It's not a hint at all. It's a mechanical tool; it marks 
>> symbols with internal linkage, and it also doesn't emit them 
>> if it's never referenced.
>> The compiler may not choose to ignore that behaviour, it's 
>> absolutely necessary, and very important.
>
> Manu, your understanding of inlining is very wrong. Maybe you 
> refer to C's __inline__ (with which I'm not familiar)?

Since C99 it's as you've described above. Before that it was 
implementation defined as it was not part of the language but 
compiler dependent.
The behaviour was very different between gcc 3 and gcc 4, after 
that it was as you described above.
I came up with a complex scheme of macros to be able to handle 
inlining efficiently, and portably for our project that was (and 
still is) pure C.

The issue with inlining for a project like ours, is that we have 
a set of libraries and binaries that a linked against these 
libraries. Some of the apps have to be linked to static versions 
of the libs, other to .so version of them, this is 3 variants, 
optimized for deployment, debug with a lot of diagnistics and 
profiling.

This requires that all inline functions have their code emitted 
exactly once in exactly one library, regardless if the caller 
inlined it or not. Not as easy as people think.




More information about the Digitalmars-d mailing list