preprocessor pass equivalent?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Mar 16 17:15:15 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.
[...]

Alright, so I hacked dmd a little to make this a runtime option: I
changed the default symfile extension from .d to .ds so that it won't
overwrite the original source files, and added the option -sym to turn
it on/off. Check it out:

	https://github.com/quickfur/dmd/tree/gensymfile

Playing around with it a little, I notice that it doesn't output
template bodies, even though calls to template functions are left
intact. It also doesn't expand [] into opIndex/opIndexAssign, for
example. So you can't actually compile the output if you're using
templates, AFAICT.

I'm guessing that by this point the compiler has stored all templates in
a symbol table somewhere, so it only has the bare template declarations
left.


T

-- 
The peace of mind---from knowing that viruses which exploit Microsoft system vulnerabilities cannot touch Linux---is priceless. -- Frustrated system administrator.


More information about the Digitalmars-d-learn mailing list