DMD "preprocessed"-source output?

Ary Borenszweig ary at esperanto.org.ar
Sun Oct 5 08:01:41 PDT 2008


Nick Sabalausky escribió:
> I don't suppose DMD has any way to output a copy of what the source files 
> look like after things like mixins, CTFE and versions are applied? (Sort of 
> like running a C compiler with a "preprocess-only" flag). I don't see 
> anything like this in the listed command-line params, but maybe I missed it.
> 
> I have a program (that makes heavy use of mixins and CTFE and such) that 
> gives wildly different output between two different versions of DMD/Tango 
> (Tango's documented "breaking changes" don't appear to be the culprit and 
> nothing in DMD's changelog or the latest bugzilla entries seem to 
> immediately stick out). I'm sure I can track it down, but it would help to 
> narrow things down if I could run the "preprocessed" results from both 
> environments through a file diff. 

Just for fun, I'll make a view in Descent that will show you exactly 
that. I believe DMD has all the information to output that, but not a 
switch. It'll also help me detect easier if there's a bug in CTFE or 
template instantiation (in Descent's port).

Note that this will turn things like:

const int x = 1 + 2 + 3 + 4;

into

const int x = 10;

and:

const int x = someFuncThatCanBeEvaluatedAtCompileTime(2);

into:

const int x = 20;

I don't know if this is good or bad...

I'll let you know when I'll have it done.


More information about the Digitalmars-d-learn mailing list