On 2/6/23 14:48, Bruno Haible wrote:
* In the long term, assuming ISO C 23 and newer, writing (void) is just
clutter in those places where one can just as well write (). The keyword
'void' here only tells that the programmer has accomplished the migration
from K&R C to ISO C 23, nothing else.
* We can assume that the readers and contributors of our code know the
difference between a function declaration/type and a function definition.
Therefore, I'm in favour of turning all (void) in function*definitions*
to ().
This can happen now or any time.
This all makes sense, yes.
* We should stop compiling with -Wstrict-prototypes and instead (not always,
but frequently enough) compile with the '-std=gnu23' option. Clang
currently implements it better. GCC 13 may be on par with clang again on
this topic [1].
We could have 'configure' check -Wstrict-prototypes specially. If the
compiler complains about the abovementioned style, 'configure' would
omit -Wstrict-prototypes; otherwise it could keep it. The idea is that
eventually GCC will be smart enough so that 'gcc -Wstrict-prototypes'
will do the right thing even when not in C23 mode.
I filed a GCC bug report about this:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108690
* We need to continue to use (void) in function declarations/types, as long
as we support compilers for ISO C standards before C 23. This will
probably take 10 or 15 years.
Alternatively we could define a macro NOARGS that expands to nothing in
C23 and later, and to void otherwise. This might be more trouble than
it's worth, though.