4

In essence I want to write

MACRO(a, b, c)

and have it result in

"a","b","c"

I tried using #__VA_ARGS__, but it results in one string containing all arguments:

"a, b, c"

which is not what I want.

user697683
  • 1,423
  • 13
  • 24
  • Maybe you could clarify if the call is always 3 arguments `MACRO(a, b, c)` or if it could contain any parameters. – Lundin Jun 25 '18 at 11:23
  • Looks like you'd need something recursive: `#define MACRO(a, ...) #a, MACRO(__VA_ARGS__)`. You need a special case anyway for the last argument as it's not followed by a comma. – MSalters Jun 25 '18 at 11:34
  • [Demo](https://ideone.com/NP3Hdm) – Jarod42 Jun 25 '18 at 17:10

1 Answers1

-3
#define MACRO3(a, b, c) #a,#b,#c

Make one for each argument count you might use

M.M
  • 138,810
  • 21
  • 208
  • 365