Re: compiler warnings on mingw

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: compiler warnings on mingw
Дата
Msg-id CABUevEyeZfUvaYMuNop3NyRvvRh2Up2tStK8SXVAPDERf8p9eg@mail.gmail.com
обсуждение исходный текст
Ответ на compiler warnings on mingw  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
On Mon, Jun 25, 2012 at 11:42 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
> 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,

Seems like a proper fix to me - but could be verified by checking what
the actual mingw header looks like. Or maybe that's what you did
already..


> Oddly, the mingw buildfarm member[1] complains about
>
> mingwcompat.c:66: warning: no previous prototype for 'RegisterWaitForSingleObject'

I think that one is just laziness - in the case when we're injecting
that API function into mingw we should declare it in our own headers.
It was likely just left out because the proper API headers already
carry it, it was just missing in mingw.. So it hsould be added to the
port header, under an #ifdef.


> instead.  So there might be some divergent header files around.
>
> Anyone know details about this?

Perhaps mingw has added it to their api *properly* this time, and the
whole function should go away from mingwcompat.c? In that case it'd
obviously require a configure test, since it doesn't exist in previous
releases.


> #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.)

can't commend on that part without more investigation.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: compiler warnings on mingw
Следующее
От: Ryan Kelly
Дата:
Сообщение: Re: [PATCH] Allow breaking out of hung connection attempts