How can I write compile-time (pure) BigInt computations?

Timon Gehr timon.gehr at gmx.ch
Tue Oct 25 07:15:50 PDT 2011


On 10/25/2011 04:01 PM, renoX wrote:
> == Extrait de l'article de « Timon Gehr (timon.gehr at gmx.ch) »
>> BigInt operates using hand-written assembly, if available for the
> target architecture.
>> inline asm cannot be used in CTFE.
>
> A reasonable restriction, but I don't understand why this prevent
> BigInt to be used in CTFE as BigInt also implement the functions
> without the inline asm.
> Why do the compiler set the D_InlineAsm_X86 target during the CTFE
> pass?
>
> Best regards,
> renoX
>
>

D_InlineAsm_X86 is a global version identifier. The functions to compile 
are selected before semantic analysis (and CTFE) is run on them. The 
compiler has no way to know that the other branch indeed provides 
CTFE-able functions, the code could just as well look like this:


version(D_InlineAsm_X86) {
     ...
} else version(...){
...
} else {
     static assert(0, "unknown platform");
}


More information about the Digitalmars-d mailing list