Is there anyway to see what you code looks like after the preprocessor has done all the substitutions?
+6
A:
That depends on your compiler. With gcc
, you would use:
gcc -E source.c
caf
2009-11-12 01:13:07
thanks you, for the fast and accurate responce, i should havce mention i was ussing gcc.
Oxinabox
2009-11-12 01:15:24
+5
A:
For gcc jus 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.
jitter
2009-11-12 01:14:29
For MSVS users, see this old question: http://stackoverflow.com/questions/1719234/see-what-the-preprocessor-is-doing
DarenW
2010-01-16 21:02:16
+5
A:
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
2009-11-12 01:20:28
A:
Eclipse C++ IDE (CDT) has macro exploration control, which can be used for:
- obtaining final macro expansion
- looking threw expansion process step-by-step
This is called Macro Exploration control.
Konstantin
2009-11-26 10:57:40