Hi Paul,

On Sat, Jun 07, 2025 at 03:37:27PM -0700, Paul Eggert wrote:
> 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.

Thanks!

> As a caveat,
> it requires at least one function argument if you want to be portable to
> C99, as C99 prohibits empty initializers.

I've been wondering tonight: this implies that all arguments in
__VA_ARGS__ are integers, doesn't it?  A pointer wouldn't work, as the
array would initialize an int with a pointer without a cast.


Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature

Reply via email to