dummzeuch 1505 Posted January 1, 2020 (edited) Given a unit that exports a function that should be inlined: unit bla; {$INCLUDE 'jedi.inc'} interface function blub: integer; implementation function blub: integer; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} begin Result := SomeCalculationHere; end; Is it OK to put the inline only in the implementation? Or does it also have to go to the declaration in the interface section? It compiles OK this way, but I don't know whether it would still be inlined. I'm asking because I would like to keep the interface as clean as possible which means avoiding to clutter it with an ifdef. Edited January 1, 2020 by dummzeuch Share this post Link to post
David Hoyle 68 Posted January 1, 2020 I generally put these kind of functions in a record to group them and only put the inline directive in the interface however I do place a {$IFNDEF DEBUG} around the inline directive as I’ve found that I could not step through the methods while debugging. I know you need to keep the GExperts code backwards compatible so the record group is just a nice to have thing. Share this post Link to post
David Heffernan 2345 Posted January 1, 2020 As it stands, in your code it will only be inlined in the code in the same unit as the implementation, and only for calls in functions declared after the inline method implementation. You can check this yourself by inspecting the disassembly of calling code. 1 Share this post Link to post
FredS 138 Posted January 1, 2020 1 hour ago, David Hoyle said: {$IFNDEF DEBUG} around the inline directive With include files one can change the inline option and skip all those IFNDEFs, tested with Berlin and up. In this case the include file includes a CustomInclude.inc, which is part of the project. This makes it simple to edit in the IDE as required. /// <remarks> /// NOTE: You can override this in CustomInclude.inc, but it requires a Build /// and won't update the Blue Dots /// </remarks> {$IFNDEF RELEASE} {-$INLINE OFF} // un-comment as needed {$ENDIF RELEASE} 2 2 Share this post Link to post
Fr0sT.Brutal 900 Posted January 9, 2020 On 1/1/2020 at 3:31 PM, dummzeuch said: I don't know whether it would still be inlined. Just try to F7 into that function. Share this post Link to post