Re: compilers and unused args in functions

2024-07-05 Thread Greg A. Woods
At Fri, 5 Jul 2024 10:03:05 -0400 (EDT), Mouse wrote: Subject: Re: compilers and unused args in functions > > One is > > (void)arg; This is, in my opinion, the one correct way to explicitly and with intent "use" an otherwise unused variable or parameter. It is after all idiomatic C when u

Re: compilers and unused args in functions

2024-07-05 Thread наб
On Fri, Jul 05, 2024 at 10:03:05AM -0400, Mouse wrote: > In...C++, I think it is?, you can do this by declaring the unused arg > without a name, as in > > void fxn(int arg1, int) > { > ... > } > > but as far as I know nobody's picked that up in C. (It strikes me as a > very sensible approach.)

Re: compilers and unused args in functions

2024-07-05 Thread Mouse
> One of those functions needs a 2nd arg, which means that to keep > compatible function profiles these days, I need to add the extra arg > to all of them Or complicate the call sites, yes. > In the ancient past I would have just added an extra arg to the one > that needs it, and the call site, a

Re: compilers and unused args in functions

2024-07-05 Thread Robert Elz
Date:Fri, 5 Jul 2024 10:20:23 +0200 From:=?UTF-8?Q?J=C3=B6rg_Sonnenberger?= Message-ID: | How do you know which functions take one argument and which two? They all take two now. That was the question (now answered) - what should I do with the extra arg in those

Re: compilers and unused args in functions

2024-07-05 Thread Jörg Sonnenberger
On 7/5/24 6:36 AM, Robert Elz wrote: In sh, I have a whole set of functions that are called via a function pointer in a data struct (*p->func)(arg); One of those functions needs a 2nd arg, which means that to keep compatible function profiles these days, I need to add the extra arg t