How to get the preprocessed C / C++ source files?
Everybody knows that before the real compilation, the source file will undergo the stage called preprocessing. All the compiler preprocessors such as #include, #define etc will be processed in this stage and that intermediate preprocessed file, which is the real source – will be fed to compiler for compiling. Its a bit difficult to troubleshoot problems with preprocessor( especially macro expansions ) because, the processed intermediate file is not available. But is to possible to get it?
Ofcourse. You can use the compiler option /P. Take the project settings, In the C/C++ tab add the /P to compiler options. See the screenshot below.
Now if you take your source folder, you can see files with extension *.i
So if you’ve some trouble in macro expansion, just generate the intermediate file and check.
Open the generated intermediate file and see the contents. I’m sure you can’t believe your eyes.
Targeted Audience – Beginners.