emacs-devel
[Top][All Lists]
Advanced

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

Re: What is the recommended way to find out the number of arguments pass


From: dalanicolai
Subject: Re: What is the recommended way to find out the number of arguments passed to a module function?
Date: Wed, 10 Jan 2024 21:41:56 +0100

Thanks Eli.

Also, I realize now, that sizeof works differently on an array and a pointer (to an array) (AFAIU).
I guess I will slowly or quickly get used to these (initial) pitfalls.


On Wed, 10 Jan 2024 at 21:10, Eli Zaretskii <eliz@gnu.org> wrote:
> From: dalanicolai <dalanicolai@gmail.com>
> Date: Wed, 10 Jan 2024 21:05:22 +0100
>
> Ah okay, well I am completely new to C, so I am still finding out things (e.g. I have not 'actively' used
> ptrdiff yet).
> But indeed the 'nargs' just give the number of passed args (obviously).
>
> I had checked the 'sizeof' the args array when passing an argument and without passing an
> argument,
> and it was the same. Then the docs mention that NARGS is the 'required' number of arguments,
> I had misunderstood it a little (of course the required number is variable, but somehow I assumed it
> would be 1 in this case). So sometimes I overlook the 'obvious', and because I had spent some time
> on testing
> things already, I decided to just ask here.

The args[] array gets allocated exactly to accommodate nargs
arguments, so you should never access args[] beyond the index nargs-1.

> Anyway, as usual, thanks for your quick and helpful answer!

You're welcome.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]