Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Smita Kapse

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;
}

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.