On 2025-06-07 13:21, Alejandro Colomar wrote:
On Sat, Jun 07, 2025 at 09:47:49PM +0200, Basil L. Contovounesios wrote:
I tried using Gnulib's countof macro for counting the number of
arguments passed to a variadic function, e.g.:

   #define CALL(fn, args) ((fn) (countof (args), (args)))
   #define CALLN(fn, ...) CALL (fn, ((int []) {__VA_ARGS__}))
Huh!  This is quite interesting.  :-)

I introduced CALLN to Emacs in 2015 and it has proved useful. As a caveat, it requires at least one function argument if you want to be portable to C99, as C99 prohibits empty initializers.

Reply via email to