Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preprocessor output

People also ask

What is C preprocessor output?

Preprocessing is a stage where preprocessor directives are expanded or processed before source code is sent to the compiler. The most common example of such directive is #include or #define. A preprocessor output has “. i” extension.

What is preprocessor statement?

Preprocessor statements are handled by the compiler (or preprocessor) before the program is actually compiled. All # statements are processed first, and the symbols (like TRUE) which occur in the C program are replaced by their value (like 1).

What is input to the preprocessor?

If you specify both the MACRO and INSOURCE options, the compiler lists input to the preprocessor, one record per line, each line numbered sequentially at the left. If the preprocessor detects an error or the possibility of an error, it prints a message on the page or pages following the input listing.

What is the output of C program with preprocessor directives?

9) What is the output of C program with preprocessor directives.? Explanation: You can define a constant using Preprocessor directive even inside a main() function or any other function. So CVV is replaced by 199 everywhere it appears.


gcc -E file.c

or

g++ -E file.cpp

will do this for you. The -E switch forces the compiler to stop after the preprocessing phase, spitting all it’s got at the moment to standard output.

Note: Surely you must have some #include directives. The included files get preprocessed, too, so you might get lots of output.

For Visual C++ the switch is /E which spits the preprocessor output to screen.


You can also call the C Preprocessor directly.

cpp infile outfile

Check out man cpp for more info.


For GCC,

gcc -E -dM file.c

or

g++ -E -dM file.cpp

should do the job. -dM, as GNU Preprocessor manual puts it, should generate a list of ‘#define’ directives for all the macros defined during the execution of the preprocessor, including predefined macros.


It depends on the compiler you use.
With GCC, you can specify the -E flag on the command-line to let the compiler produce the pre-processor output.