如何在两个单独的步骤中运行MSVC预处理器和编译器? [英] How can I run the MSVC preprocessor and compiler in two separate steps?

查看:43
本文介绍了如何在两个单独的步骤中运行MSVC预处理器和编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行Microsoft Visual Studio编译器 cl.exe 而不调用预处理器。这可能吗?我以为只要编译经过预处理的源代码(使用 / c 标志)就可以使预处理器运行为空,但显然并非如此。我做了一些基准测试。这是一个小的源文件( main.cpp ),其中仅包含一些代码:

  #include< iostream> 
#include< string>
#include< windows.h>

以下是一些不同的编译器调用及其时间:

 
1:cl / c main.cpp〜1.02s
2:cl / EP main.cpp> main-preprocessed.cpp〜0.5s
3:cl / c main-preprocessed.cpp〜0.75s

似乎预处理源代码的编译已经快了一点(预处理器并没有需要做任何事情)。但是,1和2之间的差异表明实际的编译器和汇编器只需要多0.5s。因此,编译经过预处理的源代码(如步骤3所示)比我希望的要慢一些。预处理器?我对从MSVC6到MSVC10的解决方案感兴趣。

解决方案

据我所知,如果没有Windows XP,将无法运行编译器。预处理程序(不管它什么都不做。



但是,将两个阶段分开显然会很慢,因为您要向文件中添加写操作然后再读回如果不需要执行这些写操作,则可以将其保存在内存中,这样可以节省大量时间,等待磁盘写入&读取。



ie即使可以禁用预处理器,它仍然比同时运行两个阶段要慢。


I'd like to run the Microsoft Visual Studio Compiler cl.exe without invoking the preprocessor. Is this possible? I thought that simply compiling preprocessed source code (using the /c flag) would make the preprocessor run being a no-op, but apparently that's not the case. I did a bit of benchmarking. Here's a little source file (main.cpp) which just includes some code:

#include <iostream>
#include <string>
#include <windows.h>

Here are some different compiler invocations and their timings:

1: cl /c main.cpp                             ~1.02s
2: cl /EP main.cpp > main-preprocessed.cpp    ~0.5s
3: cl /c main-preprocessed.cpp                ~0.75s

It seems that compiling preprocessed source code is already a bit faster (the preprocessor doesn't need to do anything). However, the difference between 1 and 2 suggests that the actual compiler and assembler just needs a bit more 0.5s. So compiling the preprocessed source code (as done in step 3) is a bit slower than I hoped.

Is there any way to just run the compiler and assembler, without invoking the preprocessor? I'm interested in solutions for MSVC6 up to MSVC10.

解决方案

To my knowledge there is no way to run the compiler without the preprocessor (regardless of the fact that it doesn't do anything.

However seperating the 2 stages will obviously be slower as you are adding a write to file and then read back of that file. If it doesn't need to do those writes it can hold it in memory and you save a tonne of time waiting for the disk to be written to & read from.

ie Even if you could disable the pre-processor it would still be slower than running both stages simultaneously.

这篇关于如何在两个单独的步骤中运行MSVC预处理器和编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆