you could use the following compiler switches. /C preserve comments during preprocessing. /E copy preprocessor output to standard output (with #line) /EP copy preprocessor output to standard output (without #line) /P write preprocessor output to a file.
To set this programmatically, use the VCCLCompilerTool class. VCCLCompilerTool::GeneratePreprocessedFile property provides the same functionality.