Related question here: How can I run the MSVC preprocessor and compiler in two separate steps?
I explicitly pre-process a MyFile.cpp (not compile) to a MyFile.i. I want to later “compile” that file (explicitly skipping preprocessing would be nice, but as the related question suggests, it sounds like that is not possible with MSVS.)
PROBLEM: The MyFile.i is an “unrecognized extension”, and cl.exe assumes it is an “object file” resulting in a “no-operation”. (See Microsoft warning: http://msdn.microsoft.com/en-us/library/zfsbakc5(v=VS.90).aspx, this warning is active for MSVS 2005, 2008, 2010).
I can’t find a switch to state that it is a “source file” (not an object file). The related question explicitly used the “MyFile_preprocessed.cpp” convention, but I’d really rather stay with the (more-universal) MyFile.i convention.
QUESTION: Is there a flag where I can compile a MyFile.i with MSVS?
cl.exehas these two flags/Tc<source file>compile file as .c/Tp<source file>compile file as .cppthat lets you compile files with arbitrary extension as c or c++ files
I tried compiling a
main.iwith the following contentswith
cl /Tp main.iand it works as advertised