Skip to content

Support GNU C (x, ## __VA_ARGS__) omit comma. #219

@jwnhy

Description

@jwnhy

GNU C supports a non-standard feature that allows one to omit the variadics without the additional comma.

For example,

#define pr_fmt(fmt, ...) printf(fmt, __VA_ARGS__)

pr_fmt("HELLO") will expand to printf("HELLO", ) with an additional comma ,, which is not ideal.

GNU C introduces the feature that if adds a preceding ##, the additional comma will automatically be removed.

#define pr_fmt(fmt, ...) printf(fmt, ## __VA_ARGS__)

This produces printf("HELLO").

Given that there is already some implementation in C++ 2a around ommitable variadics here, it shouldn't be too hard to support this feature.

Linux kernel extensively uses this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions