Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Richard Harnden Newsgroups: comp.lang.c Subject: Re: is it possible to have functions with 0, 1, or 2 args? Date: Mon, 12 Aug 2024 11:37:39 +0100 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <7q-dnbTDU4oBES37nZ2dnZfqnPednZ2d@brightview.co.uk> <20240805151946.00000bce@yahoo.com> <86wmkmfhaz.fsf@linuxsc.com> <8634naccp3.fsf@linuxsc.com> Reply-To: nospam.harnden@invalid.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 12 Aug 2024 12:37:40 +0200 (CEST) Injection-Info: dont-email.me; posting-host="cd70aad63c7f641afd772a48c24ad4f0"; logging-data="3427994"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UJBeiTnQld0W8MyEBdKm/41sgATOkyzA=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:G/DlBIjJG1CQxWp24NDqPcmuW7w= Content-Language: en-US In-Reply-To: <8634naccp3.fsf@linuxsc.com> Bytes: 2494 On 12/08/2024 10:28, Tim Rentsch wrote: > Richard Harnden writes: > >> On 12/08/2024 06:20, Tim Rentsch wrote: >> >>> Michael S writes: >>> >>>> On Mon, 05 Aug 2024 08:26:04 +0000 >>>> Mark Summerfield wrote: >>>> >>>> According to my understanding, vararg functions without arguments will >>>> become possible in C23. But since fully functional C23 compilers do not >>>> exist yet, right now the answer to your question is "No". >>> >>> Even in C99 varargs functions can be called without arguments. >>> The question here is more subtle. In fact it is possible even >>> in C99 and C11 to do what he wants, but it isn't easy, and it >>> is far from obvious how to go about it. Still, if the question >>> is "can this be done?", the answer is Yes even now. >> >> How does va_start know where to, um, start from if there's no last >> named argument? > > Sorry, I meant to say macros, not functions (using ... and __VA_ARGS__). > The original question is about macro definitions, not function > definitions, and I didn't read carefully enough. No worries. So ... how can you do it with macros? And, even if it's possible, is it a good idea?