Skip to content

#ifdefs inside variable args macro breaks the parser #1071

Description

@vesim987

Minimal repro:

#define va_args_expand(...) __VA_ARGS__

va_args_expand (
#ifdef __riscv
    #warning riscv
#else
    #warning other
#endif
)

causes multiple errors:

foo.h:3:1: error: expected external declaration
va_args_expand (
^
foo.h:1:29: note: expanded from here
#define va_args_expand(...) __VA_ARGS__
                            ^
foo.h:5:5: note: expanded from here
    #warning riscv
    ^
foo.h:3:1: error: unknown type name 'warning'
va_args_expand (
^
foo.h:1:29: note: expanded from here
#define va_args_expand(...) __VA_ARGS__
                            ^
foo.h:5:6: note: expanded from here
    #warning riscv
     ^
foo.h:5:19: error: expected ';' before end of file
    #warning riscv
                  ^

This is reduction of https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2350/pico_platform/include/pico/platform.h#L93-L110

Activity

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions