Checking if CTFE is used?

Daniel Kozak kozzi11 at gmail.com
Tue Dec 18 13:06:41 UTC 2018


On Tue, Dec 18, 2018 at 1:25 PM berni via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> Is there a way to check if a function is indeed executed at
> compile time or not? (Other than going through the whole
> executable binaries...)
>
> I tried
>
> > static this()
> > {
> >   if (__ctfe) pragma(msg,"works");
> >   // some other stuff
> > }
>
> but unfortunatley this "if" is also executed at compile time,
> when I put it into a function that is only called at runtime.
> When I try "static if" instead the compiler complains about
> "__ctfe" being not known at compile time.
>

You could use __ctfeWrite

But it seems __ctfe does not work anymore

https://run.dlang.io/is/snckyV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20181218/322385b3/attachment.html>


More information about the Digitalmars-d-learn mailing list