Role of stdafx. h header file standard application fram extend Without a function library, some environment parameters are defined so that the compiled program can run in a 32-bit operating system environment. The include files for Windows and MFC are very large. Even if there is a fast processing program, it takes quite a long time to compile the program. Since each. cpp file contains the same include file, it is silly to process these files repeatedly for each. cpp file. To avoid this waste, Appwizard works with the VisualC ++ compiler as follows: 1. Appwizard creates the stdafx. h file, which contains all the current project files that require mfcinclude. This file can change with the selected options. 2. Appwizard and create stdafx. cpp. This file is usually the same. 3. Then Appwizard will create the project file, so that the first compiled file is stdafx. cpp. 4 When Visual C ++ compiles the stdafx. cpp file, it stores the result in a file named stdafx. PCH. (The extension PCH indicates the precompiled header file .) 5. When Visual C ++ compiles each subsequent. cpp file, it reads and uses the. PCH file it just generated. VisualC ++ does not analyze windowsinclude files any longer, unless you have compiled stdafx. cpp or stdafx. h. (Also, Microsoft is not the first company to adopt this technology, Borland is .) In this process, you must follow the following rules: 1. Any. cpp file you write must first contain stdafx. h. 7. If you have a majority of. cpp files in the project file that require. H files, add them to stdafx. H (back) and pre-compile stdafx. cpp. 2. Because the. PCH file has a lot of symbolic information, it is the largest file in your project file. If your disk space is limited, you want to delete the. PCH file from the project file you have never used. They are not required when the program is executed, and they are automatically re-established as the project file is re-established Stdafx. the H file contains some necessary header files (such as afxwin. h), corresponding to stdafx. h has an stdafx. CPP file, which contains the following sentence: # include "stdafx. H ", which enables the compiler to compile an stdafx. OBJ pre-compiled header file (pre-compile header, which requires the compilation option) to reduce the total Compilation Time at next compilation. If you use classwizard to define a new class, you may add new include files in stdafx. h. For example, if you use the MFC template classes, the: # include <afxtempl. h> is added to stdafx. h. Note: 1. afxwin. H is a required file for MFC programming, including the header files required for running the cstring and cedit classes. It is best to ensure that this sentence is in the first line of the header file; it will also call windows. h. The header package contains the definition of data types, API entry points, and other useful parameter information; 2. the most common problem when using the MFC library for non-MFC projects is windows. h Repeated inclusion error: Fatal error c1189: # error: Windows. h already included. MFC APPs must not # include <windows. h>; 3. # define win32_leanand_mean, refuse to accept the MFC class library in the Windows header file to accelerate the compilation time; 4. AF in afx-afx refers to the abbreviation of application frame. Once a technical development team specialized in application frame, afx was used to name the team, and X had no meaning, it only constitutes a loud slogan, which has been used for a long time. 5. # If _ msc_ver> 1000 // indicates the version # Pragma once // avoid mutual inclusion between header files # Endif // _ msc_ver> 1000 6. create a new empty project, stdafx in the project. CPP uses the create precompiled header (/YC. CPP is the use precompiled header (/YU), and the CREATE/use PCH trhough file is stdafx. h
|