Accelerate C ++ language compilation speed using the pre-translated head file

xiaoxiao2021-03-06  69

Although the performance of the machine is getting faster, the C language itself has become more and more complex, compared to other mainstream languages ​​in the same period, alone. The files of a project are often incrude a lot of headers. Most of these headers are fixed unchanged, and they need to resource and time when compiling each file. At this time, you can use the pre-translated head file to solve this problem, speed up the compilation speed. Pre-compilation refers to the compiler first compiles a header file (called the pre-translated header file), then save this compile result as an image after use, then if there is other source files include this "pre-translated head file" Time, automatically load the already saved image file rather than re-reading the resolution source file. You can construct a similar file if you use other compilers that support pre-compilation. 4, use the precompiled image, use the pre-compiled result refers to compiling a.cpp, if a.cpp first row include statement is #include "stdafx.h" (or other precompiled head file), then directly Press the results of the compilation result file, no longer recompile "stdafx.h"

Using method A, all written relatively stable .h files (such as C language libraries, standard template libraries, third-party fixed libraries) are written in the precompiled head file.

2, all source files are added to the #include "preheader.h" (or other pre-translated head file name). If this header is not summarized, it must be indicated when compiling does not use the pre-translated header file.

VC: Using the pre-compiled head file in the project properties -> C -> Pre-compiled head file -> settings, the first compilation selection is created, then change it to use, no construction is used to automatically create G at 3.4. Start support Pre-translated head file, but only as a "Technology Preview"

转载请注明原文地址:https://www.9cbs.com/read-88546.html

New Post(0)