Alex Rivera | Logout

C preprocessor Macro defining Macro

Asked 2010-03-11T22:34:48.970
58

Can you do something like this with a macro in C?

#define SUPERMACRO(X,Y) #define X Y

then

SUPERMACRO(A,B) expands to #define A B

I have a feeling not because the preprocessor only does one pass.

Official gcc only. No third-party tools please.

Edit
Report

1 Answer

-2

You might do this though: #define SUPERMACRO(X,Y) define X Y

Then you can use your editors macro-expansion functionality and paste in the missing #.

Or even better: Use a different, more powerful string-processing language as your preprocessor.

answered 2013-02-21T15:53:02.530

Your Answer