C + + Learning--the first program

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.