libpq build problem with <io.h> on MS VC++ 7.0

Andrew Francis <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32
Message-ID <[email protected]>
Hi all

When building libpq using Visual Studio .NET 2002 (ie Visual C++ 7.0), I 
encounter this error:

fe-lobj.c
C:\Program Files\Microsoft Visual Studio .NET\Vc7\include\io.h(205) : error 
C2375: 'pgrename' : redefinition; different linkage
         c:\libs\postgresql\src\include\port.h(148) : see declaration of 
'pgrename'
C:\Program Files\Microsoft Visual Studio .NET\Vc7\include\io.h(275) : error 
C2375: 'pgunlink' : redefinition; different linkage
         c:\libs\postgresql\src\include\port.h(149) : see declaration of 
'pgunlink'


As rename/unlink are #define'd to pgrename/pgunlink prior to <io.h>'s inclusion.


Simply reordering the headers fixes the problem (see attachment).


I believe this may be a problem on my compiler, but not necessarily others, 
due to an additional compiler directive on the definition in io.h:

   #define _CRTIMP __declspec(dllimport)
      ...
   _CRTIMP int __cdecl unlink(const char *);

port.h's definition of pgrename() is obviously lacking a __declspec(dllimport).


Regards,

-- 
Andrew Francis
Lead Developer - Software
Family Health Network


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html
fe-lobj-fix.diff (text/plain, 1.1 KB)
*** fe-lobj-old.c	Wed Aug 11 14:56:16 2004
--- fe-lobj.c	Wed Aug 11 14:55:55 2004
***************
*** 13,33 ****
   *-------------------------------------------------------------------------
   */
- #include "postgres_fe.h"
  
! #include <fcntl.h>
! #include <sys/stat.h>
! #include <errno.h>
  
  #ifdef WIN32
  #include "win32.h"
- #include "io.h"
  #else
  #include <unistd.h>
  #endif
  
  #include "libpq-fe.h"
  #include "libpq-int.h"
  #include "libpq/libpq-fs.h"		/* must come after sys/stat.h */
- 
  
  #define LO_BUFSIZE		  8192
--- 13,40 ----
   *-------------------------------------------------------------------------
   */
  
! #ifdef WIN32
! /*
!  * As unlink/rename are #define'd in port.h (via postgres_fe.h), io.h
!  * must be included first.
!  */
! #include <io.h>
! #endif
! 
! #include "postgres_fe.h"
  
  #ifdef WIN32
  #include "win32.h"
  #else
  #include <unistd.h>
  #endif
  
+ #include <fcntl.h>
+ #include <sys/stat.h>
+ #include <errno.h>
+ 
  #include "libpq-fe.h"
  #include "libpq-int.h"
  #include "libpq/libpq-fs.h"		/* must come after sys/stat.h */
  
  #define LO_BUFSIZE		  8192
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.