Using Pre-Compiled Headers technology to accelerate compilation speed - Take Borland C ++ Builder as an Example (1)

zhaozj2021-02-17  53

Using Pre-Compiled Headers technology to accelerate compilation speed - Take Borland C Builder as an Example (1)

Author: Wang Sen Taiwan Jiaotong University Institute of Technology Management moli.mt88g@nctu.edu.tw

Every program designer has a common experience: When the program is more and more, you need to recompile the executive file each time, it is often necessary to have a long time. This is a dream. . The good idea is usually missed during this long compilation process. Of course, we can purchase higher file hardware make the compilation speed faster. However, the speed of hardware upgrades will never go up with the speed of the program code (this seems to come out with each new version of Windows, we always feel that the computer is getting more and more slowly, but the same thing is the same as the same work). Several friends who use delphi to complain that time is too long, they always smile and advise me to use Delphi, because Delphi's compilation speed is really fast, and use delphi, almost can do any development tools on Windows. Get something. The author has always been a loyal C supporter (this is an emotional factor, there is no meaning of any language), I also spend a lot of time to study how to make the program written by BCB can be compiled faster, let more time Take the error or play an idea. This article is my research experience in this area. In this article, the author is all as discussed by the latest BCB 5.0. At first I assume that the reader did not use the experience of BCB, the first part of the article is specially written to beginners. If you are a BCB programming designer with extensive experience, you can skip the first , directly from the second paragraph . If you are very patient from the beginning, I hope that in the first paragraph some personal experience can help you readers.

First, let's establish a simple console program to use the post-test. Please select File / New to open the New Item dialog, select console wizard at the New page, as shown below:

After pressing the OK button, the following screen appears:

Please check on the Use VCL with the CONSOLE Application of Check Box in accordance with the image above. The console wizard will automatically generate a program backbonate, as shown below.

Then please use this procedure (unit1.cpp) and project file (Project1.bpr) to save the disk in a separate new directory, and we store them in the TEST directory, after the first time stores, only the whole directory is only Several files, as shown below:

Additionally, many friends will find that there will be many files in the directory where the project is located each time, usually, I don't know which one should be deleted. In the case of our original project, when we press Project / make Project1, the directory will generate the files in the following picture:

For future backups, we can delete some unnecessary files. The following table lists the relevant information:

Can the file function delete? *. ~ * Original backup file can be * .tds intermediate file * .Obj intermediate file * .RES compiled resource file can be * .exe execut file

For some part of the original code backup file, whenever we store files, as long as the file is originally existing in the directory, the IDE will automatically change the original file into *. ~ *, Then rewrite the files you want to store. Hard drive. For example, Unit1.cpp, if the reply is reused, IDE changes the file name to Unit. ~ CPP, then store the latest unit1.cpp back to the hard disk. If you think this is a bit annoying, even if you feel that there is no need, then please choose Tools / Editor Options to open the dialog box below: Take the Create Backup file this Check Box, so that Ide Never help us do backup work. In addition, each CPP file will generate an OBJ file after compiling, so when the program is, the resulting OBJ file will be more and more, and it is a bit a bit more troublesome when the backup is backup. This author provides a suggestion, which is to let the compiler uniformly put the compiled OBJ file below a directory. When we will delete all the files in this directory. In order to do this, select Project / Option to turn the following dialog box:

As shown, in the intermediate output in the Directories / Conditional page, the TMP is filled in the interface. The last point is that BCB 5.0 is in the form of compilation on the background, so each time we press Make or Build, unless compiling problems, the compilation process dialog will automatically turn off. In order to observe the compilation process, select Tools / Environment Options to open the following dialog box:

Take the check box of Background Compilation, so the process of compilation is like the version before BCB 5.0, each compiles, the compilation process dialog box in the middle of the screen, as shown below:

OK, the front homework is successful, then we have to start doing some test!

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

New Post(0)