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

Generated on Mon Feb 15 18:22:41 2010 for libpqxx by  doxygen 1.5.5