From 04c8d4c66082c1717ff73ec0c4eb4b447502c7fd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 22 Jan 2002 19:02:40 +0000 Subject: [PATCH] libpq++/pgconnection.h must not include postgres_fe.h, else it fails to compile in client apps that use the standard installed header set. To allow removing that include, move DLLIMPORT definitions out of c.h and into the appropriate port-specific header files. --- src/include/c.h | 25 +++--------------------- src/include/pg_config.h.in | 13 +++++++++++-- src/include/pg_config.h.win32 | 28 +++++++++++++++++++++++++++ src/include/port/win.h | 26 +++++++++++++++++++++++++ src/include/port/win32.h | 27 ++++++++++++++++++++++++++ src/interfaces/libpq++/pgconnection.h | 3 +-- 6 files changed, 96 insertions(+), 26 deletions(-) diff --git a/src/include/c.h b/src/include/c.h index 74bf434acb..67484f4c96 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.113 2001/12/03 17:44:52 tgl Exp $ + * $Id: c.h,v 1.114 2002/01/22 19:02:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -620,27 +620,8 @@ typedef NameData *Name; /* These are for things that are one way on Unix and another on NT */ #define NULL_DEV "/dev/null" -/* defines for dynamic linking on Win32 platform */ -#ifdef __CYGWIN__ -#if __GNUC__ && ! defined (__declspec) -#error You need egcs 1.1 or newer for compiling! -#endif -#ifdef BUILDING_DLL -#define DLLIMPORT __declspec (dllexport) -#else /* not BUILDING_DLL */ -#define DLLIMPORT __declspec (dllimport) -#endif -#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */ -#if defined(_DLL) -#define DLLIMPORT __declspec (dllexport) -#else /* not _DLL */ -#define DLLIMPORT __declspec (dllimport) -#endif -#else /* not CYGWIN, not MSVC */ -#define DLLIMPORT -#endif - -/* Provide prototypes for routines not present in a particular machine's +/* + * Provide prototypes for routines not present in a particular machine's * standard C library. It'd be better to put these in pg_config.h, but * in pg_config.h we haven't yet included anything that defines size_t... */ diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 8e84fa4219..58987eee16 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -8,7 +8,7 @@ * or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your * changes will be overwritten the next time you run configure. * - * $Id: pg_config.h.in,v 1.15 2001/12/03 17:44:52 tgl Exp $ + * $Id: pg_config.h.in,v 1.16 2002/01/22 19:02:40 tgl Exp $ */ #ifndef PG_CONFIG_H @@ -720,10 +720,19 @@ extern int fdatasync(int fildes); #include "pg_config_os.h" +/* + * Provide default definitions for things that port-specific pg_config_os.h + * files can set, but typically don't. + */ + +#ifndef DLLIMPORT +#define DLLIMPORT /* no special DLL markers on most ports */ +#endif + /* * The following is used as the arg list for signal handlers. Any ports * that take something other than an int argument should override this in - * the port-specific pg_config_os.h file. Note that variable names are required + * their pg_config_os.h file. Note that variable names are required * because it is used in both the prototypes as well as the definitions. * Note also the long name. We expect that this won't collide with * other names causing compiler warnings. diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index 007fee40ef..eb833f3f90 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -29,4 +29,32 @@ /* use _snprintf instead of snprintf */ #define HAVE_SNPRINTF_DECL #define snprintf _snprintf + +/* defines for dynamic linking on Win32 platform */ +#ifdef __CYGWIN__ + +#if __GNUC__ && ! defined (__declspec) +#error You need egcs 1.1 or newer for compiling! +#endif + +#ifdef BUILDING_DLL +#define DLLIMPORT __declspec (dllexport) +#else /* not BUILDING_DLL */ +#define DLLIMPORT __declspec (dllimport) +#endif + +#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */ + +#if defined(_DLL) +#define DLLIMPORT __declspec (dllexport) +#else /* not _DLL */ +#define DLLIMPORT __declspec (dllimport) +#endif + +#else /* not CYGWIN, not MSVC */ + +#define DLLIMPORT + +#endif + #endif /* pg_config_h_win32__ */ diff --git a/src/include/port/win.h b/src/include/port/win.h index e22502d39f..52725a1e1a 100644 --- a/src/include/port/win.h +++ b/src/include/port/win.h @@ -15,5 +15,31 @@ typedef unsigned char slock_t; */ #if CYGWIN_VERSION_DLL_MAJOR < 1001 #undef HAVE_UNIX_SOCKETS +#endif + +/* defines for dynamic linking on Win32 platform */ +#ifdef __CYGWIN__ + +#if __GNUC__ && ! defined (__declspec) +#error You need egcs 1.1 or newer for compiling! +#endif + +#ifdef BUILDING_DLL +#define DLLIMPORT __declspec (dllexport) +#else /* not BUILDING_DLL */ +#define DLLIMPORT __declspec (dllimport) +#endif + +#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */ + +#if defined(_DLL) +#define DLLIMPORT __declspec (dllexport) +#else /* not _DLL */ +#define DLLIMPORT __declspec (dllimport) +#endif + +#else /* not CYGWIN, not MSVC */ + +#define DLLIMPORT #endif diff --git a/src/include/port/win32.h b/src/include/port/win32.h index c9bf62784b..b9ef739e9c 100644 --- a/src/include/port/win32.h +++ b/src/include/port/win32.h @@ -1,2 +1,29 @@ #define USES_WINSOCK #define NOFILE 100 + +/* defines for dynamic linking on Win32 platform */ +#ifdef __CYGWIN__ + +#if __GNUC__ && ! defined (__declspec) +#error You need egcs 1.1 or newer for compiling! +#endif + +#ifdef BUILDING_DLL +#define DLLIMPORT __declspec (dllexport) +#else /* not BUILDING_DLL */ +#define DLLIMPORT __declspec (dllimport) +#endif + +#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */ + +#if defined(_DLL) +#define DLLIMPORT __declspec (dllexport) +#else /* not _DLL */ +#define DLLIMPORT __declspec (dllimport) +#endif + +#else /* not CYGWIN, not MSVC */ + +#define DLLIMPORT + +#endif diff --git a/src/interfaces/libpq++/pgconnection.h b/src/interfaces/libpq++/pgconnection.h index 217006f3b7..9e025abe2d 100644 --- a/src/interfaces/libpq++/pgconnection.h +++ b/src/interfaces/libpq++/pgconnection.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pgconnection.h,v 1.14 2001/09/30 22:30:37 tgl Exp $ + * $Id: pgconnection.h,v 1.15 2002/01/22 19:02:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,6 @@ extern "C" { #endif extern "C" { -#include "postgres_fe.h" #include "libpq-fe.h" }