Use pre-compiled headers technology to accelerate compilation speed - taking Borland C ++ Builder as an Example (4)

zhaozj2021-02-17  50

Use pre-compiled headers technology to accelerate compilation speed - taking Borland C Builder as an Example (4)

Author: Wang Sen Taiwan Jiaotong University Institute of Technology Management moli.mt88g@nctu.edu.tw Please look back at all this before we Program original file used to test. Take the program code 5, everyone will find that Unit2.cpp is not placed before the compiler command #pragma hdrstop, is that the author's default Unit2.cpp can't be placed before the compiler instruction #pragma HDRStop? Let us come Be a project experiment group, the program code is as follows: program code 6-1: unit1.cpp # include #include #include #include "unit2.h" #pragma HDRStop #pragma argsusedint main (int Argc, char * argv []) {cout << "Hello World"; return 0;} unit2.h # ifndef unit2h # define unit2hvoid test (void); # endifUnit2.cpp # include #include #include #include "unit2.h" #pragma hdrstopvoid test (void) {printf ("test");} then try to compile. Then we have a file to call the Unit2.h with unit2.cpp directly, change the file content to: program code 6-2: unit2.h # ifndef unit2h # define unit2hvoid test (void); Void Test1 ); # endifunit2.cpp # include #include #include #include "unit2.h" #pragma hdrstopvoid test (void) {Printf ("test");} Void Test1 (Void) {Printf ("Test1");} Re-use Make compile. In the same way, we also do a group of exact same Project as the control group, the file content is almost identical, except that we put the #include "unit2.h" after the compiler instruction #pragma HDRSTOP, we also do with the above experiment group Project The same test:

Program Code 7-1: Unit1.cpp # include #include #include #pragma hdrstop # include "unit2.h" #pragma argsusedint main (int Argc, char * Argv []) {cout << "Hello World"; return 0;} Unit2.h # ifndef unit2h # define unit2hvoid test (void); # endifUnit2.cpp # include #include # Include #pragma hdrstop # include "unit2.h" void test (void) {printf ("test");} program code 7-2: Unit2.h # ifNDef Unit2H # define unit2hvoid test (void); Void test1 (void); # endifunit2.cpp # include #include #include #pragma hdrstop # include "unit2.h" void test (void) {printf (" Test ");} void test1 (void) {printf (" test1 ");} We put the results of these two tests in the table Test results 8: Unit2.h before #pragma HDRSTOP after #pragma hdrstop Compiling the number compile time compile time compiling the number of compile lines compile time First (build) program code 6-12022458.29 First (build) program code 7-12022588.65 Second (MAKE) program code 6-100.14 Second time (MAKE) program code 7-100.16 Third (Make) program 6-22022539.16 Third (Make) program code 7-2651.68

What is the meaning of what mean?

This test result is not only the system header file can be placed before the compiler command #pragma hdrstop, the programming designer's own header is also possible. The header file is more movable, which causes the original file from the head to the end, making the compiler to re-generate new Cache files (Note: The compiler overrides the VCL50 with the same pre-compilation mark. # ?? Not to re-generate. In fact, this is not very thick, otherwise there will be a lot of Cache files with the same pre-compilation in the lib directory, so it can be bad!)

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

New Post(0)