Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Macro Expander

Tags:

c++

macros

Sometimes I run across quite complicated macros and I would like to view what they will expand to given the parameters (there are string concatenations in there as well). Is there by any chance a program out there that will expand the macros?

I am aware of the compiler flag -E but what about a single file (or preferably a single macro?)

like image 648
Samaursa Avatar asked May 05 '11 15:05

Samaursa


People also ask

How are macros expanded in C?

The LENGTH and BREADTH are called the macro templates. The values 10 and 20 are called macro expansions. When the program run and if the C preprocessor sees an instance of a macro within the program code, it will do the macro expansion. It replaces the macro template with the value of macro expansion.

How do you expand a macro?

To add the Expand macro to a page:Choose Expand from the Formatting category. Enter a Title. This is the text a user will click on to show the hidden content. Type or paste your text into the body of the macro.

What is the use of macro expansion?

In computer programming, a macro (short for "macro instruction"; from Greek μακρο- 'long, large') is a rule or pattern that specifies how a certain input should be mapped to a replacement output. Applying a macro to an input is known as macro expansion.

What handles macro expansion in C?

The C preprocessor is a macro processor that is used automatically by the C compiler to transform your program before actual compilation. It is called a macro processor because it allows you to define macros, which are brief abbreviations for longer constructs.


1 Answers

Eclipse will expand macros if you mouse over them. For macros which include other macros, Eclipse can even step through the macro expansions one step at a time.

(You can use Eclipse for this even if you normally use another IDE.)

like image 99
Josh Kelley Avatar answered Oct 31 '22 20:10

Josh Kelley