From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel 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 Message-ID: <83il41lzkj.fsf@gnu.org> References: <83jzohm23r.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16714"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: dalanicolai Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 10 21:11:22 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rNev3-00043v-0F for ged-emacs-devel@m.gmane-mx.org; Wed, 10 Jan 2024 21:11:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNeuO-0006ej-Hz; Wed, 10 Jan 2024 15:10:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNeuN-0006eb-7h for emacs-devel@gnu.org; Wed, 10 Jan 2024 15:10:39 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNeuM-0002Nw-VK; Wed, 10 Jan 2024 15:10:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=p9t1Xa1pAs41Xar9H6CSZNFQyyGLnRFa0QmXxCNr8ps=; b=HcfsO4U+wCvn H9wlDHk1oVlC6YwvbUevpA1NwjsYgD4SVfzXwBJeuziMLLVwgxzDDZNO0zsvJfOkhMYK089ESP7oG SJHKZg3yiTfUGiGX/txGYjbc6xc94dN/Gxo1zVXQvhnFupbhaZKhLoVZ3qgZSbooF/U+D39dLiRYH 8VkAF8TayyZirlE0QwiBrwqbE0QDTC6PDNeBF71xWdVmckuvNJxsBtM3Rh1ldWQa730UOs422K5Ux zTEIOV0+jyTw4wHDIzbo3qMtidKRFfBRryCi3iuL4HVxP56qWdw09tUXOHtpfDgyw4SQBtns+B2wJ TEqi5U3k6n9FwdDCDgb+lQ==; In-Reply-To: (message from dalanicolai on Wed, 10 Jan 2024 21:05:22 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:314823 Archived-At: > From: dalanicolai > 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.