Connecting Tech Pros Worldwide Forums | Help | Site Map

Macro expansion in Visual Studio

Newbie
 
Join Date: Sep 2009
Posts: 2
#1: Sep 30 '09
I was wondering if anyone knew of any tools or plug-ins for Visual Studio that can be used to capture the intermediate text files generated by the C preprocessor to enable a user to see a representation of their source file but with all macros fully expanded.

I know there is an option to force Visual Studio to generate such files but this gives you EVERYTHING (such as every header linked to the file in question, resulting in massive output files) as opposed to what I am looking for (which is basically for all #define statements to be fully expanded in the text).

Moderator
 
Join Date: Mar 2007
Location: North Bend Washington USA
Posts: 5,382
#2: Sep 30 '09

re: Macro expansion in Visual Studio


Go to your project properties and look under C/C++->Preprocessor.

Select Generate Preprocessed File.

Off you go.
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 831
#3: Sep 30 '09

re: Macro expansion in Visual Studio


The preprocessor is responsible for decoding all of the preprocessor directives; that is, the ones that start with #. This includes #define, #if, #include, #pragma, etc.

I don't know anything about Visual Studio, but I would be impressed if it could produce listings based on only a portion of the preprocessor output (#defines but not #includes).
Newbie
 
Join Date: Sep 2009
Posts: 2
#4: Oct 1 '09

re: Macro expansion in Visual Studio


Yeah, I guess you are right, I was just being somewhat optimistic, oh well, back to trawling through macros I suppose...
Reply