MSVC build broken (again)

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

The code around errcode is definitly messy. In CVS now, it actually
renames *our* errcode() function to __msvc_errcode, and exports this
from postgres.exe. This is definitly very borken.

The check for _MSC_VER > 1400 won't come true until Microsoft releases
the next verison of Visual Studio - VS2005 is 1400, not >1400.

Attached patch fixes this. Tested on MSVC and on Mingw.

//Magnus

Attachments:

vcbuild.diffapplication/octet-stream; name=vcbuild.diffDownload
Index: include/c.h
===================================================================
RCS file: c:/prog/cvsrepo/pgsql/pgsql/src/include/c.h,v
retrieving revision 1.212
diff -c -r1.212 c.h
*** include/c.h	3 Oct 2006 03:59:22 -0000	1.212
--- include/c.h	3 Oct 2006 18:34:21 -0000
***************
*** 58,65 ****
  #include "postgres_ext.h"
  #include "pg_trace.h"
  
! #if defined(__BORLANDC__) || (_MSC_VER > 1400)
  #include <crtdefs.h>
  #endif
  
  #include <stdio.h>
--- 58,67 ----
  #include "postgres_ext.h"
  #include "pg_trace.h"
  
! #if defined(__BORLANDC__) || (_MSC_VER >= 1400)
! #define errcode __msvc_errcode
  #include <crtdefs.h>
+ #undef errcode
  #endif
  
  #include <stdio.h>
Index: include/port/win32.h
===================================================================
RCS file: c:/prog/cvsrepo/pgsql/pgsql/src/include/port/win32.h,v
retrieving revision 1.60
diff -c -r1.60 win32.h
*** include/port/win32.h	3 Oct 2006 03:59:22 -0000	1.60
--- include/port/win32.h	3 Oct 2006 18:30:18 -0000
***************
*** 272,280 ****
  #define inline __inline
  #define __inline__ __inline
  
- #undef errcode
- #define errcode __msvc_errcode
- 
  #define _S_IRWXU	(_S_IREAD | _S_IWRITE | _S_IEXEC)
  #define _S_IXUSR	_S_IEXEC
  #define _S_IWUSR	_S_IWRITE
--- 272,277 ----
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Magnus Hagander (#1)
Re: MSVC build broken (again)

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

The code around errcode is definitly messy. In CVS now, it actually
renames *our* errcode() function to __msvc_errcode, and exports this
from postgres.exe. This is definitly very borken.

Would it be possible to move the whole <crtdefs.h> block into win32.h?
This would cause it to be included after <stdio.h> and friends, which
maybe is too late, but taking it out of c.h would be a lot cleaner.

regards, tom lane

#3Magnus Hagander
mha@sollentuna.net
In reply to: Tom Lane (#2)
Re: MSVC build broken (again)

The code around errcode is definitly messy. In CVS now, it actually
renames *our* errcode() function to __msvc_errcode, and

exports this

from postgres.exe. This is definitly very borken.

Would it be possible to move the whole <crtdefs.h> block into win32.h?
This would cause it to be included after <stdio.h> and
friends, which maybe is too late, but taking it out of c.h
would be a lot cleaner.

Nope, it needs to go before <stdio.h> and friends, unfortunatly.

//Magnus

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Magnus Hagander (#3)
Re: MSVC build broken (again)

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

Would it be possible to move the whole <crtdefs.h> block into win32.h?

Nope, it needs to go before <stdio.h> and friends, unfortunatly.

OK, patch committed as-is then. The whole thing still looks awfully
icky though, particularly the way pg_config_os.h is included in one
place for WIN32 and a different place everywhere else.

Would it make sense to split win32.h into two files, one that's included
in the normal pg_config_os.h place and one included after the system
includes?

regards, tom lane

#5Magnus Hagander
mha@sollentuna.net
In reply to: Tom Lane (#4)
Re: [PATCHES] MSVC build broken (again)

Would it be possible to move the whole <crtdefs.h> block

into win32.h?

Nope, it needs to go before <stdio.h> and friends, unfortunatly.

OK, patch committed as-is then. The whole thing still looks
awfully icky though, particularly the way pg_config_os.h is
included in one place for WIN32 and a different place everywhere else.

Would it make sense to split win32.h into two files, one
that's included in the normal pg_config_os.h place and one
included after the system includes?

I've been looking at doing this before, but never got around to it. It's
a bit hairy, so it's definitly not something we want to do during beta,
though. But maybe for 8.3.

//Magnus