Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoZ0X-0002Zb-IU for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Apr 2016 16:11:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aoZ0X-0000wD-3D for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Apr 2016 16:11:41 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aoYzA-0007UY-OM for pgsql-hackers@postgresql.org; Fri, 08 Apr 2016 16:10:16 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aoYz7-0001T7-Mt for pgsql-hackers@postgresql.org; Fri, 08 Apr 2016 16:10:15 +0000 Received: from mfilter23-d.gandi.net (mfilter23-d.gandi.net [217.70.178.151]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 3722441C09D; Fri, 8 Apr 2016 18:10:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter23-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter23-d.gandi.net (mfilter23-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 5oWdX4V7izwo; Fri, 8 Apr 2016 18:10:07 +0200 (CEST) X-Originating-IP: 98.122.164.227 Received: from [192.168.10.146] (unknown [98.122.164.227]) (Authenticated sender: adsend@dunslane.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 1D7F241C093; Fri, 8 Apr 2016 18:10:05 +0200 (CEST) Subject: Re: VS 2015 support in src/tools/msvc To: Christian Ullrich , Michael Paquier References: <56F41EEA.5040105@2ndquadrant.com> <56F53382.3060508@dunslane.net> <56FA9FDF.20108@2ndquadrant.com> <56FB2BF8.3060303@dunslane.net> <5705768E.4020908@dunslane.net> <5706FB7E.5070703@dunslane.net> <570792ED.2080003@chrullrich.net> <5707AC9E.7070309@dunslane.net> <5707C80F.9050709@chrullrich.net> Cc: Robert Haas , Petr Jelinek , Tom Lane , Magnus Hagander , PostgreSQL mailing lists From: Andrew Dunstan Message-ID: <5707D7DC.2030508@dunslane.net> Date: Fri, 8 Apr 2016 12:10:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <5707C80F.9050709@chrullrich.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 04/08/2016 11:02 AM, Christian Ullrich wrote: > * Michael Paquier wrote: > >> On Fri, Apr 8, 2016 at 10:05 PM, Andrew Dunstan >> 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). > OK, well, we're making progress. I can confirm that using _WIN32_WINNT = 0x0600 fixes my problems - I can build and run the regression tests. I'm inclined to define _WINSOCK_DEPRECATED_NO_WARNINGS to silence a few compiler bleatings. Do you have a fix for the LPCWSTR parameter issue? cheers andrew -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers