Hairy Pixels wrote 8 lines
> On Jun 24, 2023, at 7:18 PM, Michael Van Canneyt via fpc-pascal wrote:
>
> According to Florian, inline should not be used to begin with, since the
> compiler should be able to decide autonomously to inline a routine or not.
Doesn't this mean the compiler can dictate the binary size by inlining everything even if the programmer doesn't want that?
If we assume the compiler is really stupid, then such an outcome is possible.
But why would it want to inline everything ?
The idea of inlining is to optimize code. I assume that the compiler will be smart about it, and only inline when there is some gain to be had from inlining.
It seems to me no gain is to be had from e.g. inlining a routine of 500+ lines of code.
Presumably, in such a scenario the compiler commandline flags 'optimize for speed' and 'optimize for size' will then come into play when it needs to decide what to do.
Worst case scenario: there is a {$INLINE ON/OFF} directive which allows you to specify whether the compiler should even consider inlining or not.
Michael.