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

Open
#219 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
compilers

Research direction

Start with the existing omittable-variadics implementation in include/boost/wave/util/cpp_macromap.hpp around line 1303. Reproduce the two pr_fmt macro expansions from the issue and trace how the preprocessor handles the ## before VA_ARGS. Done means GNU C-style invocation without variadic arguments removes the preceding comma while ordinary variadic expansion remains unchanged.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C++
Stars
29
Forks
55
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/wave

All issues in boostorg/wave

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.