Re: Use func(void) for functions with no parameters

Bertrand Drouvot <bertranddrouvot.pg@gmail.com>

From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-12-05T06:35:59Z
Lists: pgsql-hackers
Hi,

On Thu, Dec 04, 2025 at 10:17:28AM -0500, Tom Lane wrote:
> Bertrand Drouvot <bertranddrouvot.pg@gmail.com> writes:
> > Yeah, what about using Pragma Directives instead, like in the
> > attached?
> 
> Yeah, a pragma is probably safer than what I was thinking about.
> But I'd be inclined to just use "#pragma GCC system_header" in
> input.h, since that's already tested and used elsewhere in the tree.

Agree.

> In any case, I don't think we should bother unless there's a push to
> enable -Wstrict-prototypes by default, which I've not heard being
> proposed.

Now that the code tree is clean, I think that this is a good timing for it.

We have been tracking and cleaning those in commits cdf4b9aff2, 0e72b9d440,
7069dbcc31, f1283ed6cc, 7b66e2c086, e95126cf04, 9f7c527af3 and recently in
9b05e2ec08a, so I think that it would make sense to "ensure" it's always tracked.

This is not just about coding style but also prevents undefined behavior (see
[1], §6.5.2.2/6). And C23 made foo() and foo(void) equivalent (see [2],
§6.7.7.4/13), so this would align with it.

If that sounds reasonable, I'd happy to work on it, thoughts?

[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
[2]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Enable -Wstrict-prototypes and -Wold-style-definition by default

  2. Use "foo(void)" for definitions of functions with no parameters.