simplecpp icon indicating copy to clipboard operation
simplecpp copied to clipboard

Example case fail from ISO/IEC N4917 section 15.6.2 example1

Open shen390s opened this issue 5 months ago • 0 comments

Case from N4917

[Example 1 :
#define LPAREN() (
#define G(Q) 42
#define F(R, X, ...) __VA_OPT__(G R X) )
int x = F(LPAREN(), 0, <:-);
 // replaced by int x = 42;
— end example]
> cat /tmp/test8.c
#define LPAREN() (
#define G(Q) 42
#define F(R,X,...) __VA_OPT__(G R X) )

int x = F(LPAREN(), 0, <:-);

run with gcc -E:

> gcc -E /tmp/test8.c 
# 0 "/tmp/test8.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/home/rshen/.guix-profile/include/stdc-predef.h" 1 3
# 0 "<command-line>" 2
# 1 "/tmp/test8.c"




int x = 42;

but it failed with simplecpp

> ./simplecpp /tmp/test8.c

/tmp/test8.c:5: syntax error: failed to expand 'F', Wrong number of parameters for macro 'G'.

Rongsong

shen390s avatar Jul 30 '25 02:07 shen390s