compiler-public.hxx

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/compiler-public.hxx
00005  *
00006  *   DESCRIPTION
00007  *      Compiler deficiency workarounds for libpqxx clients
00008  *
00009  * Copyright (c) 2002-2008, Jeroen T. Vermeulen <jtv@xs4all.nl>
00010  *
00011  * See COPYING for copyright license.  If you did not receive a file called
00012  * COPYING with this source code, please notify the distributor of this mistake,
00013  * or contact the author.
00014  *
00015  *-------------------------------------------------------------------------
00016  */
00017 #ifndef PQXX_H_COMPILER_PUBLIC
00018 #define PQXX_H_COMPILER_PUBLIC
00019 
00020 #ifdef _MSC_VER
00021 
00022 /* Work around a particularly pernicious and deliberate bug in Visual C++:
00023  * min() and max() are defined as macros, which can have some very nasty
00024  * consequences.  This compiler bug can be switched off by defining NOMINMAX.
00025  *
00026  * We don't like making choices for the user and defining environmental macros
00027  * of our own accord, but in this case it's the only way to compile without
00028  * incurring a significant risk of bugs--and there doesn't appear to be any
00029  * downside.  One wonders why this compiler wart is being maintained at all,
00030  * since the introduction of inline functions back in the 20th century.
00031  */
00032 #if defined(min) || defined(max)
00033 #error "Oops: min() and/or max() are defined as preprocessor macros.\
00034   Define NOMINMAX macro before including any system headers!"
00035 #endif
00036 
00037 #ifndef NOMINMAX
00038 #define NOMINMAX
00039 #endif
00040 
00041 // Suppress vtables on abstract classes.
00042 #define PQXX_NOVTABLE __declspec(novtable)
00043 
00044 #endif  // _MSC_VER
00045 
00046 
00047 // Workarounds & definitions that need to be included even in library's headers
00048 #include "pqxx/config-public-compiler.h"
00049 
00050 
00051 #ifdef PQXX_BROKEN_ITERATOR
00052 #include <cstddef>
00053 #include <cstdlib>
00055 
00063 namespace PGSTD
00064 {
00066 template<typename Cat,
00067          typename T,
00068          typename Dist,
00069          typename Ptr=T*,
00070          typename Ref=T&> struct iterator
00071 {
00072   typedef Cat iterator_category;
00073   typedef T value_type;
00074   typedef Dist difference_type;
00075   typedef Ptr pointer;
00076   typedef Ref reference;
00077 };
00078 }
00079 #else
00080 #include <iterator>
00081 #endif // PQXX_BROKEN_ITERATOR
00082 
00083 #ifndef PQXX_HAVE_CHAR_TRAITS
00084 #include <cstddef>
00085 namespace PGSTD
00086 {
00088 template<typename CHAR> struct char_traits {};
00090 template<> struct char_traits<char>
00091 {
00092   typedef int int_type;
00093   typedef size_t pos_type;
00094   typedef long off_type;
00095   typedef char char_type;
00096 
00097   static int_type eof() { return -1; }
00098 };
00100 template<> struct char_traits<unsigned char>
00101 {
00102   typedef int int_type;
00103   typedef size_t pos_type;
00104   typedef long off_type;
00105   typedef unsigned char char_type;
00106 
00107   static int_type eof() { return -1; }
00108 };
00109 }
00110 #endif
00111 
00112 // Workarounds for SUN Workshop 6
00113 #if defined(__SUNPRO_CC)
00114 #if __SUNPRO_CC_COMPAT < 5
00115 #error "This compiler version is not capable of building libpqxx."
00116 #endif  // __SUNPRO_CC_COMPAT < 5
00117 #define PQXX_PRIVATE __hidden
00118 #endif  // __SUNPRO_CC
00119 
00120 
00121 // Workarounds for Compaq C++ for Alpha
00122 #if defined(__DECCXX_VER)
00123 #define __USE_STD_IOSTREAM
00124 #endif  // __DECCXX_VER
00125 
00126 #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_DEPRECATED)
00127 #define PQXX_DEPRECATED __attribute__ ((deprecated))
00128 #else
00129 #define PQXX_DEPRECATED
00130 #endif
00131 
00132 // Workarounds for Windows
00133 #ifdef _WIN32
00134 
00135 
00136 /* For now, export DLL symbols if _DLL is defined.  This is done automatically
00137  * by the compiler when linking to the dynamic version of the runtime library,
00138  * according to "gzh"
00139  */
00140 // TODO: Define custom macro to govern how libpqxx will be linked to client
00141 #if !defined(PQXX_LIBEXPORT) && defined(PQXX_SHARED)
00142 #define PQXX_LIBEXPORT __declspec(dllimport)
00143 #endif  // !PQXX_LIBEXPORT && PQXX_SHARED
00144 
00145 
00146 // Workarounds for Microsoft Visual C++
00147 #ifdef _MSC_VER
00148 
00149 #if _MSC_VER < 1300
00150 #error If you're using Visual C++, you'll need at least version 7 (.NET)
00151 #elif _MSC_VER < 1310
00152 // Workarounds for pre-2003 Visual C++.NET
00153 #undef PQXX_HAVE_REVERSE_ITERATOR
00154 #define PQXX_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION
00155 #define PQXX_TYPENAME
00156 #endif  // _MSC_VER < 1310
00157 
00158 // Automatically link with the appropriate libpq (static or dynamic, debug or
00159 // release).  The default is to use the release DLL.  Define PQXX_PQ_STATIC to
00160 // link to a static version of libpq, and _DEBUG to link to a debug version.
00161 // The two may be combined.
00162 #if defined(PQXX_AUTOLINK)
00163 #if defined(PQXX_PQ_STATIC)
00164 #ifdef _DEBUG
00165 #pragma comment(lib, "libpqd")
00166 #else
00167 #pragma comment(lib, "libpq")
00168 #endif
00169 #else
00170 #ifdef _DEBUG
00171 #pragma comment(lib, "libpqddll")
00172 #else
00173 #pragma comment(lib, "libpqdll")
00174 #endif
00175 #endif
00176 #endif
00177 
00178 // If we're not compiling libpqxx itself, automatically link with the correct
00179 // libpqxx library.  To link with the libpqxx DLL, define PQXX_SHARED; the
00180 // default is to link with the static library.  This is also the recommended
00181 // practice.
00182 // Note that the preprocessor macro PQXX_INTERNAL is used to detect whether we
00183 // are compiling the libpqxx library itself. When you compile the library
00184 // yourself using your own project file, make sure to include this define.
00185 #if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
00186   #ifdef PQXX_SHARED
00187     #ifdef _DEBUG
00188       #pragma comment(lib, "libpqxxD")
00189     #else
00190       #pragma comment(lib, "libpqxx")
00191     #endif
00192   #else // !PQXX_SHARED
00193     #ifdef _DEBUG
00194       #pragma comment(lib, "libpqxx_staticD")
00195     #else
00196       #pragma comment(lib, "libpqxx_static")
00197     #endif
00198   #endif
00199 #endif
00200 
00202 
00214 #define PQXX_QUIET_DESTRUCTORS
00215 
00216 #endif  // _MSC_VER
00217 #endif  // _WIN32
00218 
00219 #ifndef PQXX_LIBEXPORT
00220 #define PQXX_LIBEXPORT
00221 #endif
00222 
00223 #ifndef PQXX_PRIVATE
00224 #define PQXX_PRIVATE
00225 #endif
00226 
00227 // Some compilers (well, VC) stumble over some required cases of "typename"
00228 #ifndef PQXX_TYPENAME
00229 #define PQXX_TYPENAME typename
00230 #endif
00231 
00232 #ifndef PQXX_NOVTABLE
00233 #define PQXX_NOVTABLE
00234 #endif
00235 
00236 #endif
00237 

Generated on Sun Nov 2 08:25:40 2008 for libpqxx by  doxygen 1.5.5