Re: Use func(void) for functions with no parameters - Mailing list pgsql-hackers

From Matthias van de Meent
Subject Re: Use func(void) for functions with no parameters
Date
Msg-id CAEze2WiT7xaGGgo1qCTZZKJASWr_jNEsOnb5EXgEOusSELMXRw@mail.gmail.com
Whole thread Raw
In response to Use func(void) for functions with no parameters  (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>)
Responses Re: Use func(void) for functions with no parameters
List pgsql-hackers
On Wed, 3 Dec 2025 at 15:51, Bertrand Drouvot
<bertranddrouvot.pg@gmail.com> wrote:
>
> Hi hackers,
>
> In C standards till C17, func() means "unspecified parameters" while func(void)
> means "no parameters". The former disables compile time type checking and was
> marked obsolescent in C99 ([1]).
>
> This patch replaces empty parameter lists with explicit void to enable proper
> type checking and eliminate possible undefined behavior (see [1]) if the function
> is called with parameters. This also prevents real bugs (API misuse for example).

LGTM, thanks!

I noticed the only changes here are for `static` definitions. Are we
just more careful with normal functions, or does the compiler complain
more easily about such "incomplete" definitions when they're in
headers or need to be linked against?


Kind regards,

Matthias van de Meent
Databricks (https://www.databricks.com)



pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Use func(void) for functions with no parameters
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] Add enable_copy_program GUC to control COPY PROGRAM