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

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Use func(void) for functions with no parameters
Date: 2025-12-05 06:35:59
Message-ID: aTJ9T8HyJN3D024w@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Dec 04, 2025 at 10:17:28AM -0500, Tom Lane wrote:
> Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2025-12-05 06:44:55 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Bryan Green 2025-12-05 05:45:16 Re: [PATCH] Allow complex data for GUC extra.