Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jwnhy opened this issue Sep 10, 2024 · 1 comment
Open

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

jwnhy opened this issue Sep 10, 2024 · 1 comment

Comments

@jwnhy
Copy link
Contributor

jwnhy commented Sep 10, 2024

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.

@jefftrull
Copy link
Collaborator

This looks interesting and useful for handling the Linux kernel, an important target for analysis. We should be sure to guard/enable it appropriately as a GNU extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants