compiler warnings on mingw

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: compiler warnings on mingw
Date: 2012-06-25 09:42:29
Message-ID: 1340617349.13589.18.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I've tried to cross-compile PostgreSQL from Linux to Windows, following
the ideas of Andrew Dunstan [0]. This works quite well. I see two
compiler warnings altogether, which might be worth getting rid of:

#1

mingwcompat.c:60:1: warning: ‘RegisterWaitForSingleObject’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]

This can apparently go away with this:

diff --git a/src/backend/port/win32/mingwcompat.c b/src/backend/port/win32/mingwcompat.c
index 0978e8c..b1a5ca5 100644
--- a/src/backend/port/win32/mingwcompat.c
+++ b/src/backend/port/win32/mingwcompat.c
@@ -56,6 +56,7 @@
(PHANDLE, HANDLE, WAITORTIMERCALLBACK, PVOID, ULONG, ULONG);
static __RegisterWaitForSingleObject _RegisterWaitForSingleObject = NULL;

+__attribute__((dllimport))
BOOL WINAPI
RegisterWaitForSingleObject(PHANDLE phNewWaitObject,
HANDLE hObject,

Oddly, the mingw buildfarm member[1] complains about

mingwcompat.c:66: warning: no previous prototype for 'RegisterWaitForSingleObject'

instead. So there might be some divergent header files around.

Anyone know details about this?

#2

pg_stat_statements.c: In function ‘pgss_ProcessUtility’:
pg_stat_statements.c:840:4: warning: unknown conversion type character ‘l’ in format [-Wformat]
pg_stat_statements.c:840:4: warning: too many arguments for format [-Wformat-extra-args]

We use a replacement snprintf and set the int64 format to %lld and %llu
based on that. But pg_stat_statements.c uses sscanf, for which we have
no replacement. The configure check comments

# MinGW uses '%I64d', though gcc throws an warning with -Wall,
# while '%lld' doesn't generate a warning, but doesn't work.

So assuming that sscanf in the mingw C library works consistently with
snprintf, that might mean that pg_stat_statements is broken on that
platform. (The claim that %lld doesn't generate a warning is also
questionable here.)

[0]: http://people.planetpostgresql.org/andrew/index.php?/archives/264-Cross-compiling-PostgreSQL-for-WIndows.html
[1]: http://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=narwhal&dt=2012-06-22%2004%3A00%3A05&stg=make

PS: Instructions for Debian:

apt-get install gcc-mingw-w64

./configure --build=$(config/config.guess) --host=i686-w64-mingw32 --without-zlib --without-readline ZIC=/usr/sbin/zic
make world

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2012-06-25 11:04:59 Re: compiler warnings on mingw
Previous Message Vlad Arkhipov 2012-06-25 08:46:36 Re: temporal support patch