preprocessor pass equivalent?
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Mar 15 07:32:45 PDT 2012
On Thu, Mar 15, 2012 at 02:51:33PM +0100, Adam D. Ruppe wrote:
> On Thursday, 15 March 2012 at 08:35:48 UTC, Jay Norwood wrote:
> >Is there some option, similar to -E gcc option, that would
> >generate the analogous listing for D?
>
> You could add one to the compiler in just
> a few lines; there's already a function that
> does it, but it isn't called from anywhere.
[...]
> $ cat test10.d
> void main() {
> auto a = 0;
> }
>
> # we have to backup because otherwise our original source will be
> lost!
> $ cp test10.d test10_original.d
>
> # you'll have to pass the paths for phobos and druntime unless you
> bring in a dmd.conf...
> $ d/dmd2/src/dmd/dmd -Id/dmd2/src/druntime/import
> -Id/dmd2/src/phobos -L-Ld/dmd2/linux/lib32/ test10.d
>
> $ cat test10.d
> // Sym file generated from 'test10.d'
> import object;
> void main()
> {
> int a = 0;
> return 0;
> }
[...]
Whoa! This is cool. I might take a stab at making this a compiler option
(and writing the output to stdout instead of overwriting the original
source). I think this will be VERY useful when learning the language,
and also when debugging a compiler bug.
T
--
EMACS = Extremely Massive And Cumbersome System
More information about the Digitalmars-d-learn
mailing list