What does 'inline' mean?

Manu turkeyman at gmail.com
Tue Jun 9 23:30:16 UTC 2020


On Wed, Jun 10, 2020 at 7:15 AM Walter Bright via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> 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.
>

It's like you skipped over ALL OF THE OTHER TEXT, where it details numerous
precise behavioural requirements :/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20200610/900ba6a0/attachment.htm>


More information about the Digitalmars-d mailing list