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.
You can select the compiler and corresponding toolset that will be used to build a project with the “Platform Toolset” property under General Configuration Properties for C++ projects. Any installed compilers that are applicable to your project type will be listed in the “Platform Toolset” dropdown.
In Visual Studio You can set compiler options for each project in its Visual Studio Property Pages dialog box. In the left pane, select Configuration Properties, C/C++ and then choose the compiler option category.
GCC is for people who don't mind spending 4 hours at the computer making it work properly. MSVC is for those who don't care about C and want it to install without any pokin' around.
In the Windows search bar, type 'settings' to open your Windows Settings. Search for Edit environment variables for your account. Choose the Path variable in your User variables and then select Edit. Select New and add the Mingw-w64 destination folder path to the system path.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With