Re: Windows 64 bit warnings

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Windows 64 bit warnings
Date: 2011-04-19 11:45:43
Message-ID: 4DAD75E7.9060608@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 04/19/2011 04:08 AM, Magnus Hagander wrote:
> IIRC, even while HANDLE is a 64-bit value on Win64, only the lower
> 32-bits are actually used. Took me a while to find a ref, but this is
> one I found: http://msdn.microsoft.com/en-us/library/aa384203(v=vs.85).aspx

Good.

>> I think all we need here is a way to shut up the overly-anal-retentive
>> warning. I would have expected that explicit cast to be enough,
>> actually, but apparently it's not. Ideas?
> Not sure about that one. Certainly seems like that case should be
> enough - it always was enough to silence similar warnings on MSVC in
> the past...
>

If we cast the HANDLE to a long long first and then truncate it the
compiler is silent, it only complains if that's done in one operation.

So maybe something like:

#ifdef WIN64
#define ULONGPID(x) (unsigned long) (unsigned long long) (x)
#else
#define ULONGPID(x) (unsigned long) (x)
#endif

...

printf(_("running on port %d with pid %lu\n"),
port, ULONGPID(postmaster_pid));

It's a bit ugly, but we've done worse.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2011-04-19 11:59:19 Re: Warning during PostgreSQL 9.0.4 libpq.dll build on WinXP+MinGW
Previous Message Pavel Golub 2011-04-19 11:09:01 Warning during PostgreSQL 9.0.4 libpq.dll build on WinXP+MinGW