Featured post
visual c++ - What is the fastest way to get just the preprocessed source code with MSVC? -
i'm trying find fastest way complete preprocessed source code (i don't need #line information other comments, raw source code) c source file.
i have following little test program includes windows header file (mini.c
):
#include <windows.h>
using microsoft visual studio 2005, run command:
cl /nologo /p mini.c
this takes 6 seconds generate 2.5mb mini.i file; changing to
cl /nologo /ep mini.c > mini.i
(which skips comments , #line information) needs 0.5 seconds write 2.1mb of output.
is aware of techniques improving further, without using precompiled headers?
the reason i'm asking wrote variant of popular ccache tool msvc. part of work, program needs compute hash sum of preprocessed source code (and few other things). i'd make fast possible.
maybe there dedicated preprocessor binary available, or other command line switches might help?
update: 1 idea came mind: define win32_lean_and_mean macro strip out lots of needed code. speeds above preprocessor run factor of approx 3x.
you're repeatedly processing same source file (<windows.h>
) in turn pulls in lot of other files. <windows.h>
located in default sdk directory.
now, processing unchanging file takes serious time. yet can rely on not changing - it's part of public interface, after all. hence preprocess - strip out comments, instance - , pass version cl /ep
.
of course, typically i/o bound task, significant cpu part intermixed. approach processes multiple sources in parallel total throughput. measuring single source preprocesing times isn't relevant.
finally, measure time write output nul
. shouldn't including time needed write mini.i
disk, since you'll intend pipe output md5sum
.
- Get link
- X
- Other Apps
Comments
Post a Comment