digitalmars.D.learn - How do I do printf/writefln debugging in CTFE?
- Chad J (23/23) May 12 2012 Hi,
- Dmitry Olshansky (5/28) May 13 2012 Try pulling this guy (aka __ctfeWrite):
- Chad J (2/8) May 13 2012 Cool, thanks!
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?
May 12 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
May 13 2012
On 05/13/2012 03:32 AM, Dmitry Olshansky wrote:On 13.05.2012 6:07, Chad J wrote:Cool, thanks!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
May 13 2012