0

source.c --(preprocessing)--> temp_source.c --(compiling)--> source.elf --(linking)--> source.exe

How to view temp_source.c ?

(I just assume that this file name temp_source.c)

Edit: I'm using Diab compiler.

Van Tr
  • 5,889
  • 2
  • 20
  • 44
  • 3
    If you are using g++, try '-E' flag. – Arunmu Feb 08 '16 at 11:03
  • See this post http://stackoverflow.com/questions/4900870/can-gcc-output-c-code-after-preprocessing – terence hill Feb 08 '16 at 11:04
  • 4
    I downvoted because question doesn't mention what compiler is being used. This results in people guessing unnecessarily. Please edit the question to add missing information. – user694733 Feb 08 '16 at 11:17
  • 1
    I couldn't decide whether to downvote because you failed to provide adequate detail about what compiler you were using, or whether you failed to expend a minimal amount of effort searching for the answer yourself. The top two related questions answer this for [GCC](http://stackoverflow.com/questions/4900870/can-gcc-output-c-code-after-preprocessing) and [MSVC](http://stackoverflow.com/questions/277258/how-do-i-see-a-c-c-source-file-after-preprocessing-in-visual-studio). – Cody Gray - on strike Feb 08 '16 at 11:24
  • Flagged as unclear what you're asking. Also, `compiler-construction` is hardly an appropriate tag for something this basic. – underscore_d Feb 08 '16 at 11:45
  • Most compilers have a flag to stop after the pre-processing step -- check your compilers documentation. – John Hascall Feb 08 '16 at 14:17

4 Answers4

1

Command line interface to Microsoft Visual C++ can be used to output the preprocessed file as :

/E: preprocess to stdout (similar to GCC's -E option)
/P: preprocess to file
/EP: preprocess to stdout without #line directives
the_unknown_spirit
  • 2,518
  • 7
  • 34
  • 56
0

The gcc preprocessor is called cpp

$ cpp -o preprossed_temp.c temp.c
Robert Larsen
  • 1,018
  • 2
  • 11
  • 18
0

If you use GCC, just write:

gcc -E source.c -o temp_source.c
GTKM
  • 26
  • 5
0

On Windows

Compiler will create a intermediate file with default extension (.i)

cl /P source.c 

Compiler will redirect to stdout

cl /E source.c

cl /E source.c > source.txt

On Linux

$gcc -E source.c > source.txt
Mandar
  • 1,006
  • 11
  • 28