Hi, this is my preprocessor test case.
#define MACRO(x,...) x
MACRO(1,2,3)
IAR outputs "1,2,3" whereas GCC simply outputs "1". I was expecting
GCC's behavior. I worked around this by adding a level of indirection to
get IAR behaving the way I want.
#define MACRO(...) _MACRO(__VA_ARGS__)
#define _MACRO(x,...) x
MACRO(1,2,3)
With that, IAR outputs "1". Is this expected behavior for IAR?
IAR preprocessor behaving different from GCC for variable # of arguments
Started by ●July 29, 2011
Reply by ●July 30, 20112011-07-30
I neglected to mention that I was using IAR 5.20, not long after I posted this I
discovered that 5.30 had been released. After installing the new version IAR is
now consistent with GCC.
--- In m..., "jwkvam" wrote:
>
> Hi, this is my preprocessor test case.
>
> #define MACRO(x,...) x
> MACRO(1,2,3)
>
> IAR outputs "1,2,3" whereas GCC simply outputs "1". I was expecting
> GCC's behavior. I worked around this by adding a level of indirection to
> get IAR behaving the way I want.
>
> #define MACRO(...) _MACRO(__VA_ARGS__)
> #define _MACRO(x,...) x
> MACRO(1,2,3)
>
> With that, IAR outputs "1". Is this expected behavior for IAR?
>
>
--- In m..., "jwkvam" wrote:
>
> Hi, this is my preprocessor test case.
>
> #define MACRO(x,...) x
> MACRO(1,2,3)
>
> IAR outputs "1,2,3" whereas GCC simply outputs "1". I was expecting
> GCC's behavior. I worked around this by adding a level of indirection to
> get IAR behaving the way I want.
>
> #define MACRO(...) _MACRO(__VA_ARGS__)
> #define _MACRO(x,...) x
> MACRO(1,2,3)
>
> With that, IAR outputs "1". Is this expected behavior for IAR?
>
>