Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

icc 110 preprocessor __VA_ARGS__ bug

churunmin
Beginner
406 Views

I have:
#define pp_il_element(...) (1, __VA_ARGS__ pp_empty)()
I want
pp_il_element()
expand to
(1, pp_empty)()

but icc 110 expand it to
(1 pp_empty)()

There is a comma lost.

I tested this on gcc, gcc expands this to
(1, pp_empty)()
gcc is ok.

0 Kudos
2 Replies
Om_S_Intel
Employee
406 Views
Quoting - churunmin

I have:
#define pp_il_element(...) (1, __VA_ARGS__ pp_empty)()
I want
pp_il_element()
expand to
(1, pp_empty)()

but icc 110 expand it to
(1 pp_empty)()

There is a comma lost.

I tested this on gcc, gcc expands this to
(1, pp_empty)()
gcc is ok.


I am investigating this issue. Could you provide code segment that compiles with gcc?
0 Kudos
JenniferJ
Moderator
406 Views
On Windows, both icl and cl expands to the same "(1 pp_empty)" with following define.
But on Linux, icc 11.0.081 expands just like gcc.

Here is the t.c I used:

#define pp_il_element(...) (1, __VA_ARGS__ pp_empty)
typedef enum { pp_empty, pp_empty1, pp_empty2} SEnumT;

int foo(int a, SEnumT b)
{
return a+b;
}

int main(int argc, char* argv[])
{
foo pp_il_element();
return 0;
}

0 Kudos
Reply