Skip to content

Example case fail from ISO/IEC N4917 section 15.6.2 example1 #469

Open

Description

@shen390s

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions