Skip to content

NARG

Description

Count the number of arguments in a variadic macro pack, 0 through 16. Requires __VA_OPT__ (C23 / current GCC, clang, MSVC).

Usage: NARG(a, b, c) -> 3, NARG() -> 0.

Usage example (Cross-references)

Usage examples (Cross-references)
    /// concatenation in `OVERLOAD__`.
    ///
    #define OVERLOAD(name, ...)      OVERLOAD_(name, NARG(__VA_ARGS__), __VA_ARGS__)
    #define OVERLOAD_(name, N, ...)  OVERLOAD__(name, N, __VA_ARGS__)
    #define OVERLOAD__(name, N, ...) CONCAT(name##_, N)(__VA_ARGS__)
Last updated on