Make foreach_ptr macro work in C++ extensions

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: Make foreach_ptr macro work in C++ extensions
Date: 2024-10-14 20:05:42
Message-ID: CAGECzQSYG3QfHrc-rOk2KbnB9iJOd7Qu-Xii1s-GTA=3JFt49Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I've been writing a C++ extension recently and it turns out that the
foreach_ptr macro added in PG17 by one of my patches causes a
compilation failure when used in C++. This is due to C++ its stricter
rules around implicit casts from void pointers.

Attached is a tiny patch that fixes that by adding an explicit cast to
the macro. I think it would be good to backpatch this to PG17 as well,
as to not introduce some differences in the macro across versions.

(CCed Nathan because he committed the original patch)

Attachment Content-Type Size
v1-0001-Make-foreach_ptr-macro-work-in-C-extensions.patch application/x-patch 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-14 20:16:54 Re: Improving the notation for ecpg.addons rules
Previous Message Nathan Bossart 2024-10-14 20:02:22 Re: Large expressions in indexes can't be stored (non-TOASTable)