What does 'inline' mean?
Walter Bright
newshound2 at digitalmars.com
Tue Jun 9 21:11:29 UTC 2020
On 6/9/2020 4:31 AM, Atila Neves wrote:
> On Monday, 8 June 2020 at 23:19:55 UTC, Jonathan M Davis wrote:
>> On Monday, June 8, 2020 8:09:04 AM MDT Manu via Digitalmars-d wrote:
>>> On Mon, Jun 8, 2020 at 8:20 PM Walter Bright via Digitalmars-d <
>>> > C/C++ inline has always been a hint to the compiler, not a > command.
>>>
>>> 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.
>>
>> It is my understanding that in C++, inline is a hint to the compiler with
>> regards to whether a particular function call is actually inlined.
>
> That's a common misconception, and one that exists due to that being its
> original intended purpose. But nowawadays? Nope:
>
> https://en.cppreference.com/w/cpp/language/inline
"Since this meaning of the keyword inline is non-binding, compilers are free to
use inline substitution for any function that's not marked inline, and are free
to generate function calls to any function marked inline. Those optimization
choices do not change the rules regarding multiple definitions and shared
statics listed above."
I.e. it is a hint.
More information about the Digitalmars-d
mailing list