Skip to content

Do not abort when there is #ifdef in macro expansion list #572

@danmar

Description

@danmar

Example code:

#define dostuff(X) X

dostuff(
#ifdef A
    1
#endif
    -1
)

simplecpp writes an error message and aborts:

1.c:5: syntax error: failed to expand 'dostuff', it is invalid to use a preprocessor directive as macro parameter

This error message is correct and it's great that simplecpp warns for this.

But customers don't like that simplecpp aborts. Compilers will typically preprocess it without warnings. gcc preprocess it to 1-1 if A is defined, and -1 if A is not defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions