Fix C23 compiler warning

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-10-20T07:07:16Z
Lists: pgsql-hackers

Attachments

Commit a67a49648d9 fixed a compiler error under C23.  After that, there 
is one compiler warning left under C23.  It has to do with this in 
src/include/nodes/pathnodes.h:

struct IndexOptInfo
{
     ...
     /* AM's cost estimator */
     /* Rather than include amapi.h here, we declare amcostestimate like 
this */
     void        (*amcostestimate) () pg_node_attr(read_write_ignore);

This no longer works because in C23, because an empty argument list is 
now equivalent to (void), rather than an indeterminate one as before. 
And so this results in an incompatible function pointer type and 
compiler warnings.  (gcc and clang agree on this.)

I think we can fix this easily with a few struct forward declarations, 
preserving the goal of not including extra header files, like this:

struct IndexPath;
struct PlannerInfo;

struct IndexOptInfo
{
     ...
     /* AM's cost estimator */
     /* Rather than include amapi.h here, we declare amcostestimate like 
this */
     void        (*amcostestimate) (struct PlannerInfo *, struct 
IndexPath *, double, Cost *, Cost *, Selectivity *, double *, double *) 
pg_node_attr(read_write_ignore);

That way the function pointer has the correct type.  This works in older 
versions of C as well.

Commits

  1. Fix C23 compiler warning

  2. Rename C23 keyword