zic with msvc

Started by Magnus Haganderabout 19 years ago5 messages
#1Magnus Hagander
mha@sollentuna.net
1 attachment(s)

Attached patch is required to make zic build on msvc. It enables Windows
NT4 and newer functions in the windows API, so we can use CopyFileEx.

//Magnus

Attachments:

zic_msvc.diffapplication/octet-stream; name=zic_msvc.diffDownload
Index: src\timezone/zic.c
===================================================================
RCS file: c:/prog/cvsrepo/pgsql/pgsql/src/timezone/zic.c,v
retrieving revision 1.18
diff -c -r1.18 zic.c
*** src\timezone/zic.c	19 Oct 2006 20:38:48 -0000	1.18
--- src\timezone/zic.c	20 Oct 2006 17:53:43 -0000
***************
*** 6,11 ****
--- 6,14 ----
   *	  $PostgreSQL: pgsql/src/timezone/zic.c,v 1.17 2006/10/16 19:58:27 tgl Exp $
   */
  
+ #ifdef WIN32
+ #define _WIN32_WINNT 0x0400
+ #endif
  #include "postgres.h"
  
  #ifdef HAVE_GETOPT_H
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Magnus Hagander (#1)
Re: zic with msvc

"Magnus Hagander" <mha@sollentuna.net> writes:

+ #ifdef WIN32
+ #define _WIN32_WINNT 0x0400
+ #endif

Hmm ... in pg_ctl.c I see

#define _WIN32_WINNT 0x0500

Is there a reason for these to be different? Are there other places
that will need this (ie, maybe it should be in c.h instead?)

regards, tom lane

#3Magnus Hagander
mha@sollentuna.net
In reply to: Tom Lane (#2)
Re: zic with msvc
+ #ifdef WIN32
+ #define _WIN32_WINNT 0x0400
+ #endif

Hmm ... in pg_ctl.c I see

#define _WIN32_WINNT 0x0500

Is there a reason for these to be different? Are there other
places that will need this (ie, maybe it should be in c.h instead?)

Not really. The default appears to be 0x0400 for MingW (or it wouldn't
have worked before), but 0x0350 or so for Visual C++.
If we define it to 0x0500 we pull in headers that will only work on 2000
or newer. But I don't really see that as a problem - I think we said
that we don't care about earlier ones anyway. in which case it's
definitly not a problem to stick it in c.h.

//Magnus

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Magnus Hagander (#3)
Re: [HACKERS] zic with msvc

"Magnus Hagander" <mha@sollentuna.net> writes:

+ #ifdef WIN32
+ #define _WIN32_WINNT 0x0400
+ #endif

Hmm ... in pg_ctl.c I see

#define _WIN32_WINNT 0x0500

Is there a reason for these to be different? Are there other
places that will need this (ie, maybe it should be in c.h instead?)

Not really. The default appears to be 0x0400 for MingW (or it wouldn't
have worked before), but 0x0350 or so for Visual C++.
If we define it to 0x0500 we pull in headers that will only work on 2000
or newer.

Hm. Actually, if the rest of the backend compiles without this, then
I guess the real question is what's zic.c doing that needs it? pg_ctl.c
has an excuse because it's doing weird MS-specific junk, but zic.c is
supposed to be bog-standard portable code. It really shouldn't have
anything that's further out there than you could find in ten other
places in the backend.

regards, tom lane

#5Magnus Hagander
mha@sollentuna.net
In reply to: Tom Lane (#4)
Re: [HACKERS] zic with msvc
+ #ifdef WIN32
+ #define _WIN32_WINNT 0x0400
+ #endif

Hmm ... in pg_ctl.c I see

#define _WIN32_WINNT 0x0500

Is there a reason for these to be different? Are there

other places

that will need this (ie, maybe it should be in c.h instead?)

Not really. The default appears to be 0x0400 for MingW (or

it wouldn't

have worked before), but 0x0350 or so for Visual C++.
If we define it to 0x0500 we pull in headers that will only work on
2000 or newer.

Hm. Actually, if the rest of the backend compiles without
this, then I guess the real question is what's zic.c doing
that needs it? pg_ctl.c has an excuse because it's doing
weird MS-specific junk, but zic.c is supposed to be
bog-standard portable code. It really shouldn't have
anything that's further out there than you could find in ten
other places in the backend.

Only almost. There is a small function to emulate link(), which uses
CopyFileEx(). That's the one.

//Magnus