@forceInline can't inline when source code is available

ketmar via D.gnu d.gnu at puremagic.com
Wed May 27 19:58:27 PDT 2015


On Thu, 28 May 2015 02:12:10 +0000, Mike wrote:

> Shouldn't it be able to inline the "add" function since the source code
> is there in the testInline.d file?  Should I file a bug?

actually, the code is not available, as ".d" file is treated like ".di" 
file here, i.e. file with only interface declarations. fixing this will 
require to change frontend to distinguish between ".d" and ".di" files, 
and will be inconsistent.

but you can fix your code instead: declare your function as template:
  @inline int add()(int a, int b) { return a+b; }

this way it will work, and it will be consistent, as ".di" files includes 
source for templates.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20150528/39461b9f/attachment.sig>


More information about the D.gnu mailing list