Skip to content

defined() not recognizing ## token paste in its operand (GNU extension) #653

Description

@wjakobsson

When defined() appears inside a macro with ## op, syntaxError gets emitted.

error: failed to evaluate #if condition, undefined function-like macro invocation: defined( ... ) [syntaxError]
#if NRF_MODULE_ENABLED(FOO)

Reproducer: main.c

#define NRF_MODULE_ENABLED(module) \
    (defined(module ## _ENABLED) && (module ## _ENABLED))

#define FOO_ENABLED 1

#if NRF_MODULE_ENABLED(FOO)
int foo(void) { return 1; }
#endif

This is caused by the DEFINED branch in expandToken, which doesn't match defined(A ## B), and makes the token 'defined(...)' fall through.

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