views:

124

answers:

4

I am analyzing a legacy code which heavily using macro , I am lost in understanding how macro are expanding in code.

Could any one suggest me some tool or technique so that i can study actual code generated from macro expansion.

Platform : Windows XP Language : C++ Compiler : VC6

Thanks in Advance

+4  A: 

Run the pre-processor (cpp) on the source file.

Nikolai N Fetissov
Chen has shown how to do this using GCC. With VC, you need to pass `/i`.
sbi
+6  A: 

To run the GCC as a pre-processor only do:

gcc -E source-file.cc > processed-source-file.cc

It also do all the #includes that you may or may not want.

Chen Levy
sat
+1  A: 

Since you're using Visual C this doesn't help you, but it might be helpful to others to mention:

Netbeans 6.7 is able to display the macro expanded version of C/C++ code in a separate window during editing.

therefromhere
thanks i will try with Netbeans, I wont compile but can edit using it :)
sat
+5  A: 

With visual studio you can use the Generate Preprocessed File option.

In the properties for your project select

C/C++/Preprocessor/

In that tab there is an option to:

generate a preprocessed file.

Select Yes, with numbers.

chollida