Error: llroundl cannot be interpreted at compile time, because it has no available source code

Steven Schveighoffer schveiguy at gmail.com
Mon Jun 8 18:55:32 UTC 2020


On 6/8/20 2:08 PM, mw wrote:
> Hi,
> 
> I'm trying to build this package:
> 
> https://code.dlang.org/packages/fixed
> 
> however, the compiler error out:
> 
> ldc2-1.21.0-linux-x86_64/bin/../import/std/math.d(5783,39): Error: 
> llroundl cannot be interpreted at compile time, because it has no 
> available source code
> 
> Looks like it does some CTFE, but
> 
> 1) I cannot find where CTFE happens in:
> 
> https://github.com/jaypha/fixed/blob/master/src/jaypha/fixed.d

Are you statically initializing a Fixed type?

e.g. (in global scope):

auto myFixedVal = Fixed!2("1.5");

That constructor call is done via CTFE. The constructor calls 
std.math.lround. lround uses libc, which has no source available.

> 2) even it does so, but why such simple function as lroundl cannot be 
> CTFE-ed?

The simplicity of the function has nothing to do with whether it can be 
CTFE. It has to do with the source code being available (as the error 
message indicates).

Note that the fix for the package would be to have an alternate CTFE 
branch, or to quit using libc.

An alternative package was created here to fix a different issue (that 
strings are converted to double to convert to the proper integer type), 
but it too will use libc when initializing a fixed point type from a 
double: https://github.com/m3m0ry/fixedpoint

So depending on your usage, it may solve your problem. Plus, it's 
actually being currently maintained, I don't think the original package is.

-Steve


More information about the Digitalmars-d-learn mailing list