What does 'inline' mean?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jun 12 15:36:18 UTC 2020


On 6/12/20 9:57 AM, Patrick Schluter wrote:
> 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.

Yes, such batteries of macros are the norm in large projects. I'm 
familiar with those in the HHVM project: 
https://github.com/facebook/hhvm/blob/a0ca1ffa9a3d690ad57feadf27031886f8eeb2f7/hphp/util/portability.h



More information about the Digitalmars-d mailing list