How do I do printf/writefln debugging in CTFE?

Chad J chadjoan at __spam.is.bad__gmail.com
Sat May 12 19:07:48 PDT 2012


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?


More information about the Digitalmars-d-learn mailing list