Varargs macros subtly broken

Jamie Lokier
Wed Sep 27 09:03:00 GMT 2000

Neil Booth wrote:
>> *boggle* you mean this is broken even without varargs?  Ouch!
>No, only in the varargs case.

Ah, I see.  Here is my simplified test case, probably like yours:

  #define half(x)      ((x) / 2)
  #define apply(...)   apply2 (__VA_ARGS__)
  #define apply2(f,x)  f (x)

  apply (half, X)

Expands to `half (X)' when it should expand to `((X) / 2)'.

-- Jamie

More information about the Gcc mailing list