Skip to content

Fix various c23 compile errors - #1879

Open
reshke wants to merge 2 commits into
apache:mainfrom
reshke:fix_c23
Open

Fix various c23 compile errors#1879
reshke wants to merge 2 commits into
apache:mainfrom
reshke:fix_c23

Conversation

@reshke

@reshke reshke commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

There are several types of adjustments needed for >= C23.

  1. . Replacing an unprototyped function pointer with a prototyped function pointer
      |                                                    _Bool (*)(Node *, sanity_result_t *)
../../../src/include/optimizer/walkers.h:36:49: note: expected ‘_Bool (*)(void)’ but argument is of type ‘_Bool (*)(Node *, sanity_result_t *)’
   36 | extern bool plan_tree_walker(Node *node, bool (*walker) (), void *context, bool recurse_into_subplans);
      |                                          ~~~~~~~^~~~~~~~~~
cdbllize.c:1440:1: note: ‘motion_sanity_walker’ declared here
 1440 | motion_sanity_walker(Node *node, sanity_result_t *result)
      | ^~~~~~~~~~~~~~~~~~~~
cdbllize.c:1550:52: error: passing argument 2 of ‘plan_tree_walker’ from incompatible pointer type [-Wincompatible-pointer-types]
 1550 |                         if (plan_tree_walker(node, motion_sanity_walker, result, true))
      |                                                    ^~~~~~~~~~~~~~~~~~~~
      |                                                    |
      |                                                    _Bool (*)(Node *, sanity_result_t *)
../../../src/include/optimizer/walkers.h:36:49: note: expected ‘_Bool (*)(void)’ but argument is of type ‘_Bool (*)(Node *, sanity_result_t *)’
   36 | extern bool plan_tree_walker(Node *node, bool (*walker) (), void *context, bool recurse_into_subplans);
      |                                          ~~~~~~~^~~~~~~~~~
cdbllize.c:1440:1: note: ‘motion_sanity_walker’ declared here
 1440 | motion_sanity_walker(Node *node, sanity_result_t *result)

I used proxy-functions approach like this:

static bool
contain_motion_walk_impl(Node *node, contain_motion_walk_context *context)
{
    /* code*/
}

static bool
contain_motion_walk_adapter(Node *node, void *context)
{
    return contain_motion_walk_impl(
        node,
        (contain_motion_walk_context *) context
    );
}

This minimizes diff. there are also others way to resolve this, but this is most nit for my taste

2.) K&R-style function definition removal
with C23 this no longer compiles

static int
get_list(bits, low, high, names, ch, file)
	bitstr_t	*bits;		/* one bit per flag, default=FALSE */
	int			low, high;	/* bounds, impl. offset for bitstr */
	char		*names[];	/* NULL or *[] of names for these elements */
	int			ch;			/* current character being processed */
	FILE		*file;		/* file being read */

3.) several const qualifications added.

@tuhaihe
tuhaihe requested review from my-ship-it and yjhjstz August 3, 2026 03:54
@reshke
reshke force-pushed the fix_c23 branch 3 times, most recently from 77db252 to 6400425 Compare August 5, 2026 01:29
@reshke
reshke force-pushed the fix_c23 branch 2 times, most recently from ee829b5 to c80501e Compare August 5, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants