C + + Console Application
When we create a C + + console application that contains a precompiled header, we find that its structure is this:
1) Understand the precompiled header file: The so-called header file pre-compilation, is a project (project) used in some of the MFC standard header files (such as Windows.H, Afxwin.H) pre-compile, later when the project compiles, no longer compile this part of the header file, Use only the precompiled results. This can speed up compilation and save time. The precompiled header file is generated by compiling stdafx.cpp, named after the project name, because the precompiled header file suffix is "pch", so the resulting file is projectname.pch. The compiler uses a precompiled header file through a header file, stdafx.h. StdAfx.h This header file name can be specified in the compilation settings of project ( specified by the precompiled header setting in the C + + option in the Properties page ). The compiler believes that all code before the directive # include "StdAfx.h" is precompiled and skips the # include "StdAfx. H "instruction, use PROJECTNAME.PCH to compile all code after this instruction. Therefore, the first statement of all CPP implementation files is: #include "stdafx.h".
So stdafx.h is the precompiled header file, add the other header files we used in stdafx.h, Stdafx.cpp is responsible for compiling the precompiled header file, and the result is saved in a file with the suffix. pch. Remember:
The role of Stdafx.cpp is to put #include "stdafx.h" statements.
In order to generate precompiled header xx.pch files, (because. h files cannot be compiled for generation.) obj file ).
That's what it's all about, nothing else. It's best not to add anything else inside.
2) understanding. obj file: The . obj file is a binary destination file, which you can understand: the. obj file is compiled and generated, and we get the. obj file by compiling.
3) understand the. exe file: the. exe file is a linker linking. obj files and library files into an EXE file through the linking process.
4) understand. lib file: Static library file.
5) understanding. dll files: dynamic library files.
C + + Learning--the first program