v1-0001-Make-foreach_ptr-macro-work-in-C-extensions.patch

application/x-patch

Filename: v1-0001-Make-foreach_ptr-macro-work-in-C-extensions.patch
Type: application/x-patch
Part: 0
Message: Make foreach_ptr macro work in C++ extensions

Patch

Format: format-patch
Series: patch v1-0001
Subject: Make foreach_ptr macro work in C++ extensions
File+
src/include/nodes/pg_list.h 1 1
From 3c3e94fdb935d71c95cdbee4cfaf971c1a9b93a3 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <github-tech@jeltef.nl>
Date: Mon, 14 Oct 2024 21:54:48 +0200
Subject: [PATCH v1] Make foreach_ptr macro work in C++ extensions

C++ has stronger requirements on casting from void pointers than C. It
turns out that because of this it's impossible to use the foreach_ptr
macro in a C++ extension. This additional explicit cast makes it work in
both C and C++ extensions.
---
 src/include/nodes/pg_list.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h
index 52df93759f..d131350e10 100644
--- a/src/include/nodes/pg_list.h
+++ b/src/include/nodes/pg_list.h
@@ -485,7 +485,7 @@ for_each_cell_setup(const List *lst, const ListCell *initcell)
 		for (ForEachState var##__state = {(lst), 0}; \
 			 (var##__state.l != NIL && \
 			  var##__state.i < var##__state.l->length && \
-			 (var = func(&var##__state.l->elements[var##__state.i]), true)); \
+			 (var = (type pointer) func(&var##__state.l->elements[var##__state.i]), true)); \
 			 var##__state.i++)
 
 /*
-- 
2.43.0