1
#define TEST(X, ...)       X ## __VA_ARGS__    // (1)
#define TEST(X, args...)   X ## args           // (2)

Is there any functional difference between them ? (i.e. one of them can be used in a better way then other in certain cases). Also, are both the syntax included in C++11 ?

tshepang
  • 12,111
  • 21
  • 91
  • 136
iammilind
  • 68,093
  • 33
  • 169
  • 336

1 Answers1

2

The first syntax is standard C99 and also standard C++11. The second is, I believe, a GNU specific extension.

Managu
  • 8,849
  • 2
  • 30
  • 36
  • 1
    In C99, (2) gives you an error on gcc. I believe you meant a GNU **CPP** extension. – Jesse Good Feb 06 '12 at 04:29
  • @Jesse: I'll certainly allow that (1) and (2) are handled by the preprocessor. I'm not sure what you mean "In C99, (2) gives you an error on gcc." Do you mean when compiling with `gcc --std=c99`? Or are you compiling without the preprocessor altogether? – Managu Feb 06 '12 at 04:53
  • I belive you need `gcc -Wall -pedantic -std=c99` to produce `warning: ISO C does not permit named variadic macros`. – Jesse Good Feb 06 '12 at 05:08