simplecpp
simplecpp copied to clipboard
Example case fail from ISO/IEC N4917 section 15.6.2 example1
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