Counting the number of arguments in __VA_ARGS__

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there a way to count the number of variadic macro arguments in C?

I found a way to check if the list is empty: examine sizeof(STR((__VA_ARGS__))) where STR is a macro that stringifies its argument. If it is 3, __VA_ARGS__ is empty. I wonder if there is a less hackish approach.

The macro arguments are expressions, but not of a uniform type, so an array-based approach does not work.

--
Florian Weimer / Red Hat Product Security Team




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux