Hi, GCC cannot compile the following small testing case:
[qinzhao@localhost]$ cat t1.c extern void boo (void *addr); #define foo(addr) \ boo (addr) #define bar(instr, addr) \ (instr) (addr) void check (void *addr) { bar(foo, addr); } [qinzhao@localhost]$ sh t /home/qinzhao/Install/latest/bin/gcc -O -S t1.c t1.c: In function ‘check’: t1.c:11:7: error: ‘foo’ undeclared (first use in this function); did you mean ‘boo’? 11 | bar(foo, addr); | ^~~ t1.c:7:4: note: in definition of macro ‘bar’ 7 | (instr) (addr) | ^~~~~ t1.c:11:7: note: each undeclared identifier is reported only once for each function it appears in 11 | bar(foo, addr); | ^~~ t1.c:7:4: note: in definition of macro ‘bar’ 7 | (instr) (addr) | ^~~~~ However, if I delete the parantheses from the macro bar as following: #define bar(instr, addr) \ instr (addr) The compilation succeed. also icc can successfully compile the original small testing case. My question is: is this a bug for GCC? or this is a coding error? thanks a lot for your help. Qing