When we write a C++ program we use
g++ -Wall -o sample sample.cpp
command (file name is sample.cpp) to compile the program then we run the executable output from that process.
In this this post lets see how this compilation process happen before output an executable.
This compilation process has four main stages.
Preprocessing
In this stage preprocessor copies the contents of the included header files into the source code file, generates macro code, and replaces symbolic constants defined using #define with their values.
Normally the standard header files to be included are in "/usr/include" directory in Ubuntu. [GCC looks in several different places for headers]
We can stop the compilation process after preprocessing using
g++ -E sample.cpp
Output we get after this stage might be very long because all the header files are also included.
So directing the output to a txt file would be better.
g++ -E sample.cpp > AfterPrePros.txt