0

Programming newbie, I want to disable the compiler/linker and just look at the precompile/ preprocessor's preprocessed code for a program...not sure what this would be called or what the usual method is for doing something like this.

Using the GNU GCC compiler in Code::Blocks, and I looked thru all the various options but not sure the command or what the menu item is called/labeled.

AstroCB
  • 12,337
  • 20
  • 57
  • 73

2 Answers2

1

gcc -E source.c -o myfile.i

Here -E is a flag stand's for PRE-Process only.

And -o is another flag which stores the PRE-Processed output of source.c into myfile.i (here .i is common extension given for PRE-Processed files in gcc)

Mysterious Jack
  • 621
  • 6
  • 18
  • Thanks for giving me the exact flag for preprocess and object flag too, this answer equally helpful, but I couldn't pick both. – user3504350 Apr 22 '14 at 15:50
  • No worries,As long as its helpful. but -o is not object flag, its **OUTPUT** flag, if just type _gcc source.c -o output.exe_ this will do everything with source.c file(preprcess,compile,link this is also called build process) and stores the output into file output.exe. – Mysterious Jack Apr 23 '14 at 04:08
0

You can use the following option to see the pre-processing files. Normally the compiler will create the files on the fly while trying to create an object file. But at the end removes them.

So in order to view them you can use the command with save-temps.

The output will have the following files:

  1. hello.i-Pre-Processed Output
  2. hello.s-Assembler Output
  3. hello.o-Compiler Output

gcc -save-temps hello.c
Jamal
  • 763
  • 7
  • 22
  • 32
gsujay
  • 41
  • 3