Here we will see how to generate the preprocessed or preprocessor code from the source code of a C or C++ program.
To see the preprocessed code using g++ compiler, we have to use the ‘-E’ option with the g++.
Preprocessor includes all of the # directives in the code, and also expands the MACRO function.
Syntax
g++ -E program.cpp
Example
#define PI 3.1415 int main() { float a = PI, r = 5; float c = a * r * r; return 0; }
Output
$ g++ -E test_prog.cpp int main() { float a = 3.1415, r = 5; float c = a * r * r; return 0; }