Seems like an oversight?
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
Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 02 pragma(inline) doesnt work on local functions : DMD | ||||
---|---|---|---|---|
| ||||
Seems like an oversight?
GetFoo isn't inlined, but inlines OK if you pass -inline to the compiler Also inlines OK if you define GetFoo outside of Foo |
September 03 Re: pragma(inline) doesnt work on local functions : DMD | ||||
---|---|---|---|---|
| ||||
Posted in reply to claptrap | On Monday, 2 September 2024 at 22:16:53 UTC, claptrap wrote: >Seems like an oversight?
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 |
September 03 Re: pragma(inline) doesnt work on local functions : DMD | ||||
---|---|---|---|---|
| ||||
Posted in reply to RazvanN | On Tuesday, 3 September 2024 at 14:05:40 UTC, RazvanN wrote: >On Monday, 2 September 2024 at 22:16:53 UTC, claptrap wrote: >Seems like an oversight?
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. I consider this a bug. Note there is no semicolon after the pragma, so it is at declaration level (declaration of -Johan |