[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: |
Eli Zaretskii |
Subject: |
Re: What is the recommended way to find out the number of arguments passed to a module function? |
Date: |
Wed, 10 Jan 2024 22:10:20 +0200 |
> 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.
Re: What is the recommended way to find out the number of arguments passed to a module function?, Emanuel Berg, 2024/01/12