Re: MinGW compiler warnings in ecpg tests
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>,
Michael Meskes <meskes@postgresql.org>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-06T02:44:20Z
Lists: pgsql-hackers
On Fri, Dec 6, 2024 at 4:13 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Thomas Munro <thomas.munro@gmail.com> writes: > > Yeah. This warning is visible on CI, and on fairywren since its MSYS2 > > upgrade a couple of months ago. Old MinGW didn't like %lld (I think > > perhaps the printf from msvcrt.dll from 1996 didn't like it and MinGW > > knew that), but new MinGW doesn't like %I64d (that's interesting, but > > not relevant here because %lld is clearly the correct format string, > > and it works). We should just revert that change. Here's a patch. > > +1 Thanks for looking. Pushed, and that fixed that on fairywren. > > Those were there before the upgrade. POSIX says that environ should > > not be declared by a header, but Windows apparently declares it, or at > > least its cousin _environ, in <stdlib.h> which we include in c.h. I > > have no idea why Visual Studio doesn't warn, or why the documentation > > only tells you about _environ and not environ, or where the macro (?) > > comes from that renames it, but it passes CI and is > > warning-free on both toolchains if you just hide the offending > > declarations. > > Isn't this likely to break things for every other Windows toolchain? > I think the concept might be OK, but we need a tighter #if condition. Cool, I'll do that for MinGW only then. > An alternative could be to add the missing dllimport on Windows; > it's not clear whether other toolchains would care. I've been digging through its headers (working on a fix for the off_t bug report) and noticed in passing that it probably thinks we're re-declaring this function: https://github.com/mingw-w64/mingw-w64/blob/8bcd5fc1a72c0b6da3147bf21a4a494c81d14fae/mingw-w64-headers/crt/stdlib.h#L221 Seems like a good idea to give that a wide berth :-)
Commits
-
Fix printf format string warning on MinGW.
- d4549176eabd 17.8 landed
- b1316b78f8a9 16.12 landed
- 1cf4f781a519 15.16 landed
- 3c5c2b018d5e 14.21 landed
- 1319997df924 18.0 landed
-
Backpatch: Fix warnings about declaration of environ on MinGW
- d7aeb03d2418 13.23 landed
- 50fbd0945c57 16.11 landed
- 371d40c1a3ff 14.20 landed
- 00bdbaca6056 15.15 landed
- 0f8a2b133644 17.7 landed
-
Fix warnings about declaration of environ on MinGW.
- 7bc9a8bdd2d6 18.0 landed
-
Fix compiler warnings in ecpg tests
- 517bf2d9107f 13.0 landed