Translate sequence in macro parameters to separate macros

Posted by Alex Tiger on Stack Overflow See other posts from Stack Overflow or by Alex Tiger
Published on 2013-10-30T11:28:25Z Indexed on 2013/11/02 3:54 UTC
Read the original article Hit count: 130

Filed under:
|
|

How to acces each element in macro if the definition is like MACRO(name, seq) and the code is like:

MACRO("TheName",
   (Elem1)
   (Elem2)
   (Elem3)
)

I want to generate the next code:

MACRO("TheName",
   ELEMMACRO(Elem1)
   ELEMMACRO(Elem2)
   ELEMMACRO(Elem3)
)

Or something like that. In other words, I want to process every parameter separately (I don't care of definition, even if it will be something like

MACRO("TheName",
   Elem1,
   Elem2,
   Elem3
)

There could be more elements, there could be less. I have tried V_ARGS (I need it only for gcc), but I can only copy all the elements by that, not to process them separately.

What can I do?

P.S. Because of some reasons, I can't use Boost.

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt