c++visual-studiotemplatesmacros

Viewing compiler expanded code - C++


I learned that compiler will expand macros while compiling. Templates are also expanded at the compile time. Is there any way to see this expanded code? I am compiling using Visual Studio 2008.

any thoughts?


Solution

  • The VC++ compiler (cl.exe) supports a few command line switches for this:

    /E preprocess to stdout
    /P preprocess to file
    /EP preproscess to stdout with no #lines
    

    Additional command-line switches can be added in your project properties. In my version (VC2005), Configuration Options -> C/C++ -> Command Line -> Additional Options