[英]MSVS C++, how to compile already-preprocessed file with *.i extension?
Related question here: How can I run the MSVC preprocessor and compiler in two separate steps? 相关问题: 如何在两个单独的步骤中运行MSVC预处理器和编译器?
I explicitly pre-process a MyFile.cpp
(not compile) to a MyFile.i
. 我明确地将MyFile.cpp
(不编译)预处理为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.) 我想稍后“编译”该文件(显式跳过预处理会很好,但正如相关问题所示,听起来这对MSVS来说是不可能的。)
PROBLEM: The MyFile.i
is an "unrecognized extension", and cl.exe
assumes it is an "object file" resulting in a "no-operation". 问题: MyFile.i
是一个“无法识别的扩展名”, cl.exe
假定它是一个“目标文件”,导致“无操作”。 (See Microsoft warning: http://msdn.microsoft.com/en-us/library/zfsbakc5(v=VS.90).aspx , this warning is active for MSVS 2005, 2008, 2010). (请参阅Microsoft警告: http : //msdn.microsoft.com/en-us/library/zfsbakc5 (v = VS.90) .aspx ,此警告对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. 相关问题明确使用了“ MyFile_preprocessed.cpp
”约定,但我真的更喜欢使用(更通用的) MyFile.i
约定。
QUESTION: Is there a flag where I can compile a MyFile.i
with MSVS? 问题:是否有一个标志,我可以用MSVS编译MyFile.i
?
cl.exe
has these two flags cl.exe
有这两个标志
/Tc<source file>
compile file as .c /Tc<source file>
文件编译为.c
/Tp<source file>
compile file as .cpp /Tp<source file>
文件编译为.cpp
that lets you compile files with arbitrary extension as c or c++ files 这允许您将具有任意扩展名的文件编译为c或c ++文件
I tried compiling a main.i
with the following contents 我尝试使用以下内容编译main.i
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world \n";
return 0;
}
with cl /Tp main.i
and it works as advertised 使用cl /Tp main.i
,它的工作方式与广告一致
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.