pragma(inline) doesnt work on local functions : DMD
RazvanN
razvan.nitu1305 at gmail.com
Tue Sep 3 14:05:40 UTC 2024
On Monday, 2 September 2024 at 22:16:53 UTC, claptrap wrote:
> Seems like an oversight?
>
> ```d
> int Foo()
> {
> pragma(inline,true)
> int GetFoo() { return 42; }
> return GetFoo();
> }
> ```
>
> GetFoo isn't inlined, but inlines OK if you pass -inline to the
> compiler
>
> Also inlines OK if you define GetFoo outside of Foo
As per the docs [1]: "If at the declaration level, it affects the
functions declared in the block it controls. If inside a
function, it affects the function it is enclosed by". So you
probably just need to put the pragma(inline) in GetFoo.
RazvanN
[1] https://dlang.org/spec/pragma.html#inline
More information about the Digitalmars-d
mailing list