stdafx stands for Standard Application Fram Extend. There is no function library, but some environment parameters are defined, so that the compiled program can run in a 32-bit operating system environment.
Both Windows and MFC include files are very large, and even with a fast handler, the compiler will take a considerable amount of time to complete the job. Since each .CPP file contains the same include file, it would be silly to repeatedly process these files for each .CPP file. To avoid this waste, AppWizard works with the VisualC ++ compiler, as shown below:
1. AppWizard created the file stdafx.h, which contains all the current project files that require MFCinclude files. And this file can change depending on the option selected.
2. AppWizard then creates stdafx.cpp. This file is usually the same.
3. Then AppWizard creates the project file, so the first file to be compiled is stdafx.cpp.
4. When VisualC ++ compiles the stdafx.cpp file, it saves the results in a file named stdafx.pch. (The extension pch indicates a precompiled header file.)
5. When Visual C ++ compiles each subsequent .cpp file, it reads and uses the .pch file it just generated.
VisualC ++ no longer analyzes Windows include files unless you edit stdafx.cpp or stdafx.h again. (Besides, Microsoft is not the first company to adopt this technology, Borland is.) In the process, you must follow the following rules:
1. Any .cpp file you write must first include stdafx.h. If you have most of the .cpp files in your project, you need .h files, add them to stdafx.h (back) by the way, and then precompile stdafx.cpp.
2. Because the .pch file has a lot of symbol 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 needed when executing the program, and they are automatically re-created as the project files are re-created
The stdafx.h file contains some necessary header files (such as afxwin.h). There is a stdafx.cpp file corresponding to stdafx.h, which contains a sentence: #include "stdafx.h", which is used to make the compilation The compiler compiles a stdafx.obj pre-compile header file (pre-compile header needs to be set to compile options) to reduce the total compilation time during the next compilation. If you use ClassWizard to define a new class, it is possible to add new include files to stdafx.h. For example, if you use MFC template classes, stdafx.h will add: #include <afxtempl.h>.
Note:
1. afxwin.h is a required file for MFC programming, which contains header files such as CString and CEdit classes. It is best to ensure that the sentence is on the first line of the header file; it also calls windows.h. The header file contains Definition of data types, API entry point definitions, and other useful parameter information;
2. The most common problem when using MFC libraries for non-MFC projects is that windows.h repeatedly contains errors: fatal error C1189: #error: WINDOWS.H already included. MFC apps must not #include <windows.h>;
3. #define WIN32_LEANAND_MEAN, refuse to accept MFC libraries in the windows header file to speed up the compilation time;
4. afx-af in afx refers to the abbreviation of Application Frame. There used to be a technical development team specializing in Application Frame, and later named this team as afx. X itself has no meaning, but only constitutes a loud slogan. Has been used.
5. #if _MSC_VER> 1000 // Indicate the version
#pragma once // Avoid mutual inclusion between header files
#endif // _MSC_VER> 1000
6. A new empty project is created. The stdafx.cpp in the project uses Create Precompiled Header (/ Yc), and the other .cpp uses Use Precompiled Header (/ Yu), and Create / Use PCH Trhough File Both stdafx.h
Contact: Manager Xu
Phone: 13907330718
Tel: 0731-22222718
Email: hniatcom@163.com
Add: Room 603, 6th Floor, Shifting Room, No. 2, Orbit Zhigu, No. 79 Liancheng Road, Shifeng District, Zhuzhou City, Hunan Province