Re: Safer hash table initialization macro

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Safer hash table initialization macro
Date: 2025-12-09 09:10:39
Message-ID: CA+hUKGLYn6jxMSptjzMqBZ7ZYKQ2cewiKjg31zUR+ZR3E+mu+Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 9, 2025 at 8:27 PM Bertrand Drouvot
<bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> On Mon, Dec 08, 2025 at 11:53:02AM +0100, Jelte Fennema-Nio wrote:
> > On Sat Dec 6, 2025 at 1:56 AM CET, Thomas Munro wrote:
> +#if defined(__cplusplus)
> +#define pg_expr_has_type_p(expr, type) (std::is_same<decltype(expr), type>::value)
> +#else
> +#define pg_expr_has_type_p(expr, type) \
> + _Generic((expr), type: 1, default: 0)
> +#endif
>
> What about relying on the existing __builtin_types_compatible_p() instead of
> _Generic() here?

If we used standard C/C++ it'd work on MSVC too.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2025-12-09 09:11:50 Re: 64-bit wait_event and introduction of 32-bit wait_event_arg
Previous Message Jelte Fennema-Nio 2025-12-09 09:08:49 Re: Proposal to allow setting cursor options on Portals