pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christian Ullrich <chris@chrullrich.net>
To: Michael Paquier <michael.paquier@gmail.com>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Petr Jelinek <petr@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: VS 2015 support in src/tools/msvc
Date: Fri, 8 Apr 2016 17:02:39 +0200
Message-ID: <5707C80F.9050709@chrullrich.net> (raw)
In-Reply-To: <CAB7nPqROXyB_=-BbAXGnCdHFYUE4_+qgQAGk1swwnVQSfiab9Q@mail.gmail.com>
References: <CAB7nPqTTcRGbDxS_RA4CWn1B_KRsvN+FTpct0mTp3v3gRWQ70g@mail.gmail.com>
	<56F41EEA.5040105@2ndquadrant.com>
	<CA+TgmobzFi-AZ+OxFOxG=AjUs=dWw3Vjt-dH4NKXiJ1jEXmAeA@mail.gmail.com>
	<CAB7nPqTEkqF7E7nWcdQSvyOUAV3OGjX=rKSxFTkk03TOJGF5ng@mail.gmail.com>
	<56F53382.3060508@dunslane.net>
	<CAB7nPqSkMU3F2jV5S6tULnUpJMub-Pqc1t0H=MjOTJZFdw3jDg@mail.gmail.com>
	<CA+TgmoZ1gKfVB2r=nr5zPp9eDbzFcnauvW_awwz1xmJF_RJmBQ@mail.gmail.com>
	<56FA9FDF.20108@2ndquadrant.com>
	<CA+TgmoaRAhFtVuMfrAn9R4aeib0azhj3jb+RC9aQ2z-JTYJsag@mail.gmail.com>
	<CAB7nPqRHbMZ5eW+AcwxgkfoU1odh75osFLJKrKkQn2N1gbiceQ@mail.gmail.com>
	<56FB2BF8.3060303@dunslane.net>
	<CA+TgmoakpqU5uXDTkfaCHesFeW8N_aH5w-e991BfxkcREo7-mg@mail.gmail.com>
	<5705768E.4020908@dunslane.net>
	<5706FB7E.5070703@dunslane.net>
	<CAB7nPqR4QHFRZ1vjMo9Njy49hDAXOAjO+AEGhuCDzmhQJRagAw@mail.gmail.com>
	<570792ED.2080003@chrullrich.net>
	<5707AC9E.7070309@dunslane.net>
	<CAB7nPqROXyB_=-BbAXGnCdHFYUE4_+qgQAGk1swwnVQSfiab9Q@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

* Michael Paquier wrote:

> On Fri, Apr 8, 2016 at 10:05 PM, Andrew Dunstan <andrew@dunslane.net> wrote:
> ¥> On 04/08/2016 07:15 AM, Christian Ullrich wrote:

>>> Michael, none of your patches change this, so how does it ever build on
>>> your system?
>
> Luck. I am getting a warning but the code is able to somewhat compile:
>    src/port/chklocale.c(230): warning C4013: 'GetLocaleInfoEx'
> undefined; assuming extern returning int
> [C:\Users\IEUser\git\postgres\libpgport.vcxproj]

Weird. This assumed declaration is __cdecl, the actual function is 
__stdcall, and I think this should be guaranteed to crash.

> But that's clearly incorrect to get that. As you are saying, what we
> actually just need to do is bumping _WIN32_WINNT to 0x0600 when
> compiling with VS2015, meaning that the minimum build requirement for
> Postgres with VS2015 would be Windows Vista, and it would not be
> possible to compile it on XP or Windows server 2k3. As XP is already
> out of support, I think that this is an acceptable tradeoff, and it
> would still be possible to build Postgres on XP with older versions of
> Visual. Thoughts?

I think you confuse two things here, let's call them "build environment" 
and "build platform". The build environment is whichever Windows SDK 
(among other things) is installed; if it is a version for Vista or 
later, that just means it has the declaration in the first place, and 
has the import in kernel32.lib. The build platform is the OS the 
compiler is run on; as long as you find a compiler that understands the 
headers from your chosen SDK version, you can run it on Windows 95 if 
both of you want.

Changing _WIN32_WINNT also affects, indirectly, on which platforms the 
resulting binaries can run. Assume a macro that has an alternative 
definition, conditioned on _WIN32_WINNT >= _WIN32_WINNT_VISTA, that uses 
a function added in Vista. A binary built using this declaration, no 
matter where and when, will not run on anything older.

> Anyway, attached are updated patches. This makes the warning go away
> from my side, so I guess that it should allow Andrew to compile the
> code.

Which brings us to the next problem:

   src/port/chklocale.c(233): warning C4133: 'function': incompatible
   types - from 'const char *' to 'LPCWSTR' [...\postgres.vcxproj]

I have no idea why I get this warning; I would have expected something 
more like this:

   localetest.cpp(26): error C2664: 'int
   GetLocaleInfoEx(LPCWSTR,LCTYPE,LPWSTR,int)': cannot convert
   argument 1 from 'const char *' to 'LPCWSTR'

Apparently the warning is triggered by type mismatches in pointer 
arithmetic, although I can't see any here. Anyway, it concerns the first 
argument in this call to GetLocaleInfoEx(), which here is a const char*.

According to the documentation and the prototype, however, it should be 
an LPCWSTR, because this function is Unicode-only (has no A/W variants). 
Unless LOCALE_IDEFAULTANSICODEPAGE also changes the interpretation of 
this first argument to a single-byte string, which is not mentioned 
anywhere in the documentation and makes no sense to begin with, I don't 
think this has ever worked either.

I just tested it, and, of course, if I pass '(LPCWSTR)"de-DE"' (narrow 
string cast to LPCWSTR), the call fails with ERROR_INVALID_PARAMETER. 
With a wide string, I get the correct code page for the locale.


Also, while you're at it, could you improve the comments a bit? I have 
not yet tried following the code to see which locale formats it uses 
where ("German_Germany", "de-DE", etc.), but GetLocaleInfoEx() takes the 
short form and there is a comment about the long form right below that 
call once patched (in the old code that gets turned into an else branch).

-- 
Christian



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (134+ messages)  latest in thread

Message-ID: <5707C80F.9050709@chrullrich.net>
Permalink:  ../5707C80F.9050709@chrullrich.net/
Also on:    postgresql.org/message-id/5707C80F.9050709@chrullrich.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: chris@chrullrich.net, michael.paquier@gmail.com, andrew@dunslane.net, robertmhaas@gmail.com, petr@2ndquadrant.com, tgl@sss.pgh.pa.us, magnus@hagander.net
  Subject: Re: VS 2015 support in src/tools/msvc
  In-Reply-To: <5707C80F.9050709@chrullrich.net>
  References: <CAB7nPqTTcRGbDxS_RA4CWn1B_KRsvN+FTpct0mTp3v3gRWQ70g@mail.gmail.com> <56F41EEA.5040105@2ndquadrant.com> <CA+TgmobzFi-AZ+OxFOxG=AjUs=dWw3Vjt-dH4NKXiJ1jEXmAeA@mail.gmail.com> <CAB7nPqTEkqF7E7nWcdQSvyOUAV3OGjX=rKSxFTkk03TOJGF5ng@mail.gmail.com> <56F53382.3060508@dunslane.net> <CAB7nPqSkMU3F2jV5S6tULnUpJMub-Pqc1t0H=MjOTJZFdw3jDg@mail.gmail.com> <CA+TgmoZ1gKfVB2r=nr5zPp9eDbzFcnauvW_awwz1xmJF_RJmBQ@mail.gmail.com> <56FA9FDF.20108@2ndquadrant.com> <CA+TgmoaRAhFtVuMfrAn9R4aeib0azhj3jb+RC9aQ2z-JTYJsag@mail.gmail.com> <CAB7nPqRHbMZ5eW+AcwxgkfoU1odh75osFLJKrKkQn2N1gbiceQ@mail.gmail.com> <56FB2BF8.3060303@dunslane.net> <CA+TgmoakpqU5uXDTkfaCHesFeW8N_aH5w-e991BfxkcREo7-mg@mail.gmail.com> <5705768E.4020908@dunslane.net> <5706FB7E.5070703@dunslane.net> <CAB7nPqR4QHFRZ1vjMo9Njy49hDAXOAjO+AEGhuCDzmhQJRagAw@mail.gmail.com> <570792ED.2080003@chrullrich.net> <5707AC9E.7070309@dunslane.net> <CAB7nPqROXyB_=-BbAXGnCdHFYUE4_+qgQAGk1swwnVQSfiab9Q@mail.gmail.com> <5707C80F.9050709@chrullrich.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox