0

I have a variadic macro and a regular macro. I use them like this:

LIST(
  ELEM(a),
  ELEM(b)
  // usually about 4-8 elements
)

I would like LIST to automatically invoke ELEM on each argument so that I can write LIST(a, b) instead of LIST(ELEM(a), ELEM(b))

How can I achieve this without using a preprocessing library? A detailed explanation or a link to one would be appreciated.

P.W
  • 26,289
  • 6
  • 39
  • 76
Indiana Kernick
  • 5,041
  • 2
  • 20
  • 50
  • 2
    It seems that the [map macro](https://github.com/swansontec/map-macro) as described in [this stackoverflow answer](https://stackoverflow.com/questions/6707148/foreach-macro-on-macros-arguments) would fit your needs. if yes i would mark this as a duplicate of the other question. also *just personally* i would probably not do this in C, as i am not such an adventurous coder ;) – ramrunner Jan 27 '19 at 02:17
  • @ramrunner The MAP macro looks like it will do what I want – Indiana Kernick Jan 27 '19 at 02:47

0 Answers0