compiler-public.hxx

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/compiler-public.h
00005  *
00006  *   DESCRIPTION
00007  *      Compiler deficiency workarounds for libpqxx clients
00008  *
00009  * Copyright (c) 2002-2006, 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_LIBCOMPILER_H
00018 #define PQXX_LIBCOMPILER_H
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 #endif  // _MSC_VER
00042 
00043 
00044 // Workarounds & definitions that need to be included even in library's headers
00045 #include "pqxx/config-public-compiler.h"
00046 
00047 
00048 #ifdef PQXX_BROKEN_ITERATOR
00049 #include <cstddef>
00050 #include <cstdlib>
00052 
00060 namespace PGSTD
00061 {
00063 template<typename Cat,
00064          typename T,
00065          typename Dist,
00066          typename Ptr=T*,
00067          typename Ref=T&> struct iterator
00068 {
00069   typedef Cat iterator_category;
00070   typedef T value_type;
00071   typedef Dist difference_type;
00072   typedef Ptr pointer;
00073   typedef Ref reference;
00074 };
00075 }
00076 #else
00077 #include <iterator>
00078 #endif // PQXX_BROKEN_ITERATOR
00079 
00080 #ifndef PQXX_HAVE_CHAR_TRAITS
00081 #include <cstddef>
00082 namespace PGSTD
00083 {
00085 template<typename CHAR> struct char_traits {};
00087 template<> struct char_traits<char>
00088 {
00089   typedef int int_type;
00090   typedef size_t pos_type;
00091   typedef long off_type;
00092   typedef char char_type;
00093 
00094   static int_type eof() { return -1; }
00095 };
00097 template<> struct char_traits<unsigned char>
00098 {
00099   typedef int int_type;
00100   typedef size_t pos_type;
00101   typedef long off_type;
00102   typedef unsigned char char_type;
00103 
00104   static int_type eof() { return -1; }
00105 };
00106 }
00107 #endif
00108 
00109 // Workarounds for SUN Workshop 6
00110 #if defined(__SUNPRO_CC)
00111 #if __SUNPRO_CC_COMPAT < 5
00112 #error "This compiler version is not capable of building libpqxx."
00113 #endif  // __SUNPRO_CC_COMPAT < 5
00114 #endif  // __SUNPRO_CC
00115 
00116 
00117 // Workarounds for Compaq C++ for Alpha
00118 #if defined(__DECCXX_VER)
00119 #define __USE_STD_IOSTREAM
00120 #endif  // __DECCXX_VER
00121 
00122 #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_DEPRECATED)
00123 #define PQXX_DEPRECATED __attribute__ ((deprecated))
00124 #else
00125 #define PQXX_DEPRECATED
00126 #endif
00127 
00128 // Workarounds for Windows
00129 #ifdef _WIN32
00130 
00131 
00132 /* For now, export DLL symbols if _DLL is defined.  This is done automatically
00133  * by the compiler when linking to the dynamic version of the runtime library,
00134  * according to "gzh"
00135  */
00136 // TODO: Define custom macro to govern how libpqxx will be linked to client
00137 #if !defined(PQXX_LIBEXPORT) && defined(PQXX_SHARED)
00138 #define PQXX_LIBEXPORT __declspec(dllimport)
00139 #endif  // !PQXX_LIBEXPORT && PQXX_SHARED
00140 
00141 
00142 // Workarounds for Microsoft Visual C++
00143 #ifdef _MSC_VER
00144 
00145 #if _MSC_VER < 1300
00146 #error If you're using Visual C++, you'll need at least version 7 (.NET)
00147 #elif _MSC_VER < 1310
00148 // Workarounds for pre-2003 Visual C++.NET
00149 #undef PQXX_HAVE_REVERSE_ITERATOR
00150 #define PQXX_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION
00151 #define PQXX_TYPENAME
00152 #endif  // _MSC_VER < 1310
00153 
00154 // Automatically link with the appropriate libpq DLL (debug or release).
00155 #ifdef _DEBUG
00156 #pragma comment(lib, "libpqddll")
00157 #else
00158 #pragma comment(lib, "libpqdll")
00159 #endif
00160 
00161 // If we're not compiling libpqxx itself, automatically link with the correct
00162 // libpqxx library.  To link with the libpqxx DLL, define PQXX_SHARED; the
00163 // default is to link with the static library.  This is also the recommended
00164 // practice.
00165 // Note that the preprocessor macro PQXX_INTERNAL is used to detect whether we
00166 // are compiling the libpqxx library itself. When you compile the library
00167 // yourself using your own project file, make sure to include this define.
00168 #ifndef PQXX_INTERNAL
00169   #ifdef PQXX_SHARED
00170     #ifdef _DEBUG
00171       #pragma comment(lib, "libpqxxD")
00172     #else
00173       #pragma comment(lib, "libpqxx")
00174     #endif
00175   #else // !PQXX_SHARED
00176     #ifdef _DEBUG
00177       #pragma comment(lib, "libpqxx_staticD")
00178     #else
00179       #pragma comment(lib, "libpqxx_static")
00180     #endif
00181   #endif
00182 #endif
00183 
00185 
00197 #define PQXX_QUIET_DESTRUCTORS
00198 
00199 #endif  // _MSC_VER
00200 #endif  // _WIN32
00201 
00202 #ifndef PQXX_LIBEXPORT
00203 #define PQXX_LIBEXPORT
00204 #endif
00205 
00206 #ifndef PQXX_PRIVATE
00207 #define PQXX_PRIVATE
00208 #endif
00209 
00210 // Some compilers (well, VC) stumble over some required cases of "typename"
00211 #ifndef PQXX_TYPENAME
00212 #define PQXX_TYPENAME typename
00213 #endif
00214 
00215 #endif
00216 

Generated on Thu Feb 1 17:12:08 2007 for libpqxx by  doxygen 1.5.1