Hacker News new | past | comments | ask | show | jobs | submit login

For C gcc -E helps a lot for macros. Does C++ have a tool that expands all templates?

gcc has options for intercepting various intermediate representations of a translation unit; look into that.

I just found this in the man page (for a fairly dated version of gcc):

       -fdump-translation-unit (C++ only)
       -fdump-translation-unit-options (C++ only)
           Dump a representation of the tree structure for the entire
           translation unit to a file.  The file name is made by appending .tu
           to the source file name, and the file is created in the same
           directory as the output file.  If the -options form is used,
           options controls the details of the dump as described for the
           -fdump-tree options.
If this were Lisp, we wouldn't be scared of what "representation of the tree structure" will look like.

It doesn't say anything about whether templates are expanded/instantiated.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact