Re: C11: should we use char32_t for unicode code points?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Tatsuo Ishii <ishii(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: C11: should we use char32_t for unicode code points?
Date: 2025-10-29 18:54:34
Message-ID: 05b461bb66df0c76b14e3c17c2b92a085e470bfe.camel@j-davis.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2025-10-28 at 14:54 -0700, Jeff Davis wrote:
> [21:48:21.794] ../../src/include/port/win32_port.h: At top level:
> [21:48:21.794] ../../src/include/port/win32_port.h:254:8: error:
> redefinition of ‘struct stat’
> [21:48:21.794]   254 | struct stat                                   
> /* This should match struct __stat64 */
> [21:48:21.794]       |        ^~~~
> [21:48:21.794] In file included from /usr/share/mingw-
> w64/include/wchar.h:413,
> [21:48:21.794]                  from /usr/share/mingw-
> w64/include/uchar.h:28,
> [21:48:21.794]                  from ../../src/include/c.h:526:
> [21:48:21.794] /usr/share/mingw-w64/include/_mingw_stat64.h:40:10:
> note: originally defined here
> [21:48:21.794]    40 |   struct stat {
> [21:48:21.794]       |          ^~~~
>
> https://cirrus-ci.com/task/4849300577976320

It seems to work on the two windows CI instances just fine, but fails
mingw_cross_warning.

Apparently, <uchar.h> somehow includes (some portion of?) <sys/stat.h>
on that platform, which then conflicts with the hackery done in
<win32_port.h> (which expects to include <sys/stat.h> itself after some
special #defines).

The attached patch moves the inclusion of <uchar.h> after "port.h",
which solves the problem. It's a bit out of place, but I added a note
in the comment explaining why. I'll go ahead and commit.

Regards,
Jeff Davis

Attachment Content-Type Size
v5-0001-Use-C11-char16_t-and-char32_t-for-Unicode-code-po.patch text/x-patch 57.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-10-29 18:55:21 Re: apply_scanjoin_target_to_paths and partitionwise join
Previous Message Bruce Momjian 2025-10-29 18:47:40 Re: Why pg_dump overwrites dump file?