This patch, shall you accept it, partially implements the proposal wg14-n3792, available here:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3792.pdf Based on the implementation of __VA_OPT__, I have added the preprocessor built-in __VA_COUNT__ that expands to the number of variadic macro arugments after full macro replacement. The patch has been tested on x86_64-pc-linux-gnu; I included a simple unit test that exercises most of the desired behaviours. Since the proposal has not been accepted or widely discussed yet, I would suggest we discuss this in more detail before merging. I have already signed a copyright assignment with the FSF for another project (automake). -- With Valediction, Kamila Szewczyk (https://iczelia.net) Kamila Szewczyk (1): libcpp: partially implement proposal wg14-n3792, __VA_COUNT__ gcc/testsuite/c-c++-common/cpp/va_count.c | 35 ++ libcpp/identifiers.cc | 2 + libcpp/include/cpplib.h | 3 + libcpp/init.cc | 58 ++-- libcpp/internal.h | 3 +- libcpp/lex.cc | 24 ++ libcpp/macro.cc | 368 +++++++++++++++++++++- libcpp/pch.cc | 1 + 8 files changed, 461 insertions(+), 33 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/cpp/va_count.c -- 2.51.0
