Compiler work process

c ++ code to the generated document from the program after compiling and linking in two stages

Which is compiling the text file into .obj files

After pre-compilation 1. 2. 3. Analytical explained marker

main.cpp

#include<iostream>

void Log(const char* message);

int main()
{
    Log("Hello world!");
    std::cin.get();        
}

Log.cpp

#include<iostream>

void Log(const char* message)
{
      std::cout<<message<<endl;  
}

Math.cpp

int Multiply(int a,int b)
{
    int result=a*b;
    return result;
}

After the Solution visible .obj files corresponding to the folder in the Debug

Other obj file by file import and include cpp code according to the rules compiled with c ++

main.cpp, Log.cpp file size is over 40 k, and Math size of 4k, because Math.cpp not include other things

In pretreatment, include references to open the file, read the file references, and all the contents of the document pasted into the current cpp

If you remove the braces Log.cpp

#include<iostream>

void Log(const char* message)
{
      std::cout<<message<<endl;  

So will complain at compile time, suggested that the lack brackets. If we create a EndBrace.h contains only a "}" and then Log.cpp include it in the program is running correctly

#include<iostream>

void Log(const char* message)
{
      std::cout<<message<<endl;  
      #include“EndBrace”

ctrl + F7 shortcut keys are separately compiled, pretreated role is to open the file header, and then paste the contents of the file header to the current in cpp

 

Guess you like

Origin www.cnblogs.com/wangtianning1223/p/12605695.html