Is there anyway to see what you code looks like after the preprocessor has done all the substitutions?
Asked
Active
Viewed 1,997 times
5 Answers
8
For gcc just use the -E
switch
gcc -E
-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.
-
For MSVS users, see this old question: http://stackoverflow.com/questions/1719234/see-what-the-preprocessor-is-doing – DarenW Jan 16 '10 at 21:02
7
That depends on your compiler. With gcc
, you would use:
gcc -E source.c

caf
- 233,326
- 40
- 323
- 462
-
thanks you, for the fast and accurate responce, i should havce mention i was ussing gcc. – Frames Catherine White Nov 12 '09 at 01:15
7
Just a note about system headers (eg <stdio.h>
): they are a pain when preprocessed.
gcc -E -nostdinc file.c
or cpp -nostdinc file.c
will not include expansion of system headers.

pmg
- 106,608
- 13
- 126
- 198
1
Eclipse C++ IDE (CDT) has Macro Exploration control, which can be used for:
- Obtaining final macro expansion
- Looking through expansion process step-by-step
This is called Macro Exploration control.

DrYap
- 6,525
- 2
- 31
- 54

Konstantin Tenzin
- 12,398
- 3
- 22
- 20