How do I do printf/writefln debugging in CTFE?
Dmitry Olshansky
dmitry.olsh at gmail.com
Sun May 13 00:32:45 PDT 2012
On 13.05.2012 6:07, Chad J wrote:
> Hi,
>
> It's been a while since I've used CTFE, and I was wondering if it has
> become possible to do something like this:
>
>
> void ctfeFunc(string arg)
> {
> pragma(msg, "arg is "~arg);
> }
>
> void main()
> {
> ctfeFunc("foo");
> }
>
> That specific attempt gives me an error:
> test.d(3): Error: variable arg cannot be read at compile time
> "arg is " ~ arg
>
> I'm using a git version of dmd that reads as v2.057. I don't feel like
> upgrading thanks to bug 5278:
> http://d.puremagic.com/issues/show_bug.cgi?id=5278
> and the github situation where dmd, druntime, and phobos (and the docs?)
> all live in different github projects that aren't tracked collectively
> anywhere (last time I messed with it), thus making it sometimes
> frustrating to find buildable commits that will work with each other.
>
> I want some way to print out the state of variables in a function being
> executed at compile time. Can it be done?
Try pulling this guy (aka __ctfeWrite):
https://github.com/D-Programming-Language/dmd/pull/692
--
Dmitry Olshansky
More information about the Digitalmars-d-learn
mailing list