MSVS C++,如何编译已预处理的带有 *.i 扩展名的文件?
此处的相关问题: 如何在两个单独的步骤中运行 MSVC 预处理器和编译器?
我显式地将 MyFile.cpp
(未编译)预处理为MyFile.i
。我想稍后“编译”该文件(明确跳过预处理会很好,但正如相关问题所暗示的那样,听起来 MSVS 不可能做到这一点。)
问题: MyFile.i
是一个“无法识别的扩展名”,并且 cl.exe
假定它是一个“目标文件”,从而导致“无操作”。 (请参阅 Microsoft 警告:http://msdn。 microsoft.com/en-us/library/zfsbakc5(v=VS.90).aspx,此警告对于 MSVS 2005、2008 有效, 2010)。
我找不到一个开关来声明它是“源文件”(不是目标文件)。相关问题明确使用了“MyFile_preprocessed.cpp
”约定,但我真的宁愿保留(更通用的)MyFile.i
约定。
问题:是否有一个标志可以让我使用 MSVS 编译 MyFile.i
?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cl.exe
有这两个标志/Tc
将文件编译为 .c/Tp<源文件>
将文件编译为.cpp允许您将具有任意扩展名的文件编译为 c 或 c++ 文件
编译包含以下内容的
main.i
我尝试使用
cl /Tp main.i
它的工作原理与广告一样cl.exe
has 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.i
with the following contentswith
cl /Tp main.i
and it works as advertised