Related Articles

Related Articles

Convert C/C++ program to Preprocessor code
  • Difficulty Level : Hard
  • Last Updated : 29 Aug, 2018

We use g++ compiler to turn provided Cpp code into preprocessor code. To see the preprocessor code generated by the CPP compiler, we can use the ā€œ-Eā€ option on the command line:
Preprocessor include all the # directives in the code. and also expands MACRO function.

Syntax:
g++ -E filename.cpp
filter_none

edit
close

play_arrow

link
brightness_4
code

// MACRO named MAX initialism to 10
#define MAX 10
  
int main()
{
  
    int a = MAX, b = MAX;
  
    // Add two values.
    int c = a + b;
  
    return 0;
}

chevron_right


Running the command:

g++ -E geeks.cc

Output :

int main()
{

    int a = 10, b = 10;

    // Add two values.
    int c = a + b;

    return 0;
}

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :