| From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Cc: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: PRI?64 vs Visual Studio (2022) |
| Date: | 2025-11-19 02:13:54 |
| Message-ID: | CA+hUKGJnmzTqiODmTjf-23yZ=E3HXqFTtKoyp3TF-MpB93hTMQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Apr 2, 2025 at 2:04 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> On 31.03.25 08:28, Kyotaro Horiguchi wrote:
> > I hadn’t paid much attention to this before, but I happened to check
> > how this behaves on Windows, and it seems that with VS2022, PRId64
> > expands to "%lld". As a result, I suspect the gettext message catalog
> > won't match these messages correctly.
>
> I think this is working correctly. Gettext has a built-in mechanism to
> translate the %<PRI...> back to the appropriate %lld or %ld. See also
> <https://www.gnu.org/software/gettext/manual/html_node/c_002dformat.html>.
Interesting report though. Commit 962da900 assumed that our in-tree
printf implementation still needed to understand that %I64 stuff in
case it came to us from system headers, but it looks like it
disappeared with MSVCRT:
1. I checked with CI (VS 2019). puts(PRId64) prints out "lld".
2. MinGW's inttypes.h[1] only uses "I64" et al if you build against MSVCRT.
So I think we should delete that stuff. Attached.
I worried that GNU gettext() might still know about %I64 somewhere,
but it just expands the macros to whatever inttypes.h defines[2].
Good.
We don't even test -Dnls on the Windows CI task, so the fact that it
passes there doesn't mean much (if our tests would even pick up
<PRI*64> expansion failure, not sure). We should probably do
something about that and/or its absence from the build farm. We're
effectively counting on the EDB packaging team or end users to tell us
if we break localisation on this platform.
I was also curious to know if the nearby floating point formatting
kludge added by commit f1885386 was still needed today. CI passes
without it, and the standard is pretty clear: "The exponent always
contains at least two digits, and only as many more digits as
necessary to represent the exponent". I didn't look too closely at
the fine print, but that text was already present in C89 so I guess
MSVCRT just failed to conform on that point.
[1] https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/crt/inttypes.h
[2] https://github.com/autotools-mirror/gettext/blob/637b208fbe13f1c306f19d4f31c21fec7e9986d2/gettext-runtime/intl/loadmsgcat.c#L473
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Drop-support-for-MSVCRT-s-I64-format-strings.patch | text/x-patch | 2.3 KB |
| 0002-Drop-support-for-MSVCRT-s-float-formatting-quirk.patch | text/x-patch | 1.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2025-11-19 02:18:23 | Re: Fix typos in ExecChooseHashTableSize() |
| Previous Message | Chao Li | 2025-11-19 02:09:42 | Re: Checkpointer write combining |