Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

libcompiler.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/libcompiler.h
00005  *
00006  *   DESCRIPTION
00007  *      Compiler deficiency workarounds for libpqxx clients
00008  *
00009  * Copyright (c) 2002-2005, 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 // TODO: Restrict this to compiler versions known to be affected
00023 /* Work around a particularly pernicious and deliberate bug in Visual C++:
00024  * min() and max() are defined as macros, which can have some very nasty
00025  * consequences.  This compiler bug can be switched off by defining NOMINMAX.
00026  *
00027  * We don't like making choices for the user and defining environmental macros
00028  * of our own accord, but in this case it's the only way to compile without
00029  * incurring a significant risk of bugs--and there doesn't appear to be any
00030  * downside.  One wonders why this compiler wart is being maintained at all,
00031  * since the introduction of inline functions back in the 20th century.
00032  */
00033 #if defined(min) || defined(max)
00034 #error "Oops: min() and/or max() are defined as preprocessor macros.\
00035   Define NOMINMAX macro before including any system headers!"
00036 #endif
00037 #define NOMINMAX
00038 
00039 #endif
00040 
00041 
00042 // Workarounds & definitions that need to be included even in library's headers
00043 #include "pqxx/config-public-compiler.h"
00044 
00045 
00046 #ifdef PQXX_BROKEN_ITERATOR
00047 #include <cstddef>
00048 #include <cstdlib>
00050 
00058 namespace PGSTD
00059 {
00061 template<typename Cat,
00062          typename T,
00063          typename Dist,
00064          typename Ptr=T*,
00065          typename Ref=T&> struct iterator
00066 {
00067   typedef Cat iterator_category;
00068   typedef T value_type;
00069   typedef Dist difference_type;
00070   typedef Ptr pointer;
00071   typedef Ref reference;
00072 };
00073 }
00074 #else
00075 #include <iterator>
00076 #endif // PQXX_BROKEN_ITERATOR
00077 
00078 #ifndef PQXX_HAVE_CHAR_TRAITS
00079 #include <cstddef>
00080 namespace PGSTD
00081 {
00083 template<typename CHAR> struct char_traits {};
00085 template<> struct char_traits<char>
00086 {
00087   typedef int int_type;
00088   typedef size_t pos_type;
00089   typedef long off_type;
00090   typedef char char_type;
00091 
00092   static int_type eof() { return -1; }
00093 };
00095 template<> struct char_traits<unsigned char>
00096 {
00097   typedef int int_type;
00098   typedef size_t pos_type;
00099   typedef long off_type;
00100   typedef unsigned char char_type;
00101 
00102   static int_type eof() { return -1; }
00103 };
00104 }
00105 #endif
00106 
00107 // Workarounds for SUN Workshop 6
00108 #if defined(__SUNPRO_CC)
00109 #if __SUNPRO_CC_COMPAT < 5
00110 #error "This compiler version is not capable of building libpqxx."
00111 #endif  // __SUNPRO_CC_COMPAT < 5
00112 #endif  // __SUNPRO_CC
00113 
00114 
00115 // Workarounds for Compaq C++ for Alpha
00116 #if defined(__DECCXX_VER)
00117 #define __USE_STD_IOSTREAM
00118 #endif  // __DECCXX_VER
00119 
00120 
00121 // Workarounds for Windows
00122 #ifdef _WIN32
00123 
00124 
00125 /* For now, export DLL symbols if _DLL is defined.  This is done automatically
00126  * by the compiler when linking to the dynamic version of the runtime library,
00127  * according to "gzh"
00128  */
00129 // TODO: Define custom macro to govern how libpqxx will be linked to client
00130 #if !defined(PQXX_LIBEXPORT) && defined(_DLL)
00131 #define PQXX_LIBEXPORT __declspec(dllimport)
00132 #endif  // PQXX_LIBEXPORT _LIB
00133 
00134 
00135 // Workarounds for Microsoft Visual C++
00136 #ifdef _MSC_VER
00137 
00138 #if _MSC_VER < 1300
00139 #error If you're using Visual C++, you'll need at least version 7 (VC.NET)
00140 #elif _MSC_VER < 1310
00141 // Workarounds for pre-2003 Visual C++.NET
00142 #undef PQXX_HAVE_REVERSE_ITERATOR
00143 #define PQXX_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION
00144 #define PQXX_TYPENAME
00145 #endif  // _MSC_VER < 1310
00146 
00147 #pragma warning (disable: 4290)
00148 #pragma warning (disable: 4355)
00149 #pragma warning (disable: 4786)
00150 #pragma warning (disable: 4251 4275 4273)
00151 #pragma comment(lib, "libpqdll")
00152 
00154 
00166 #define PQXX_QUIET_DESTRUCTORS
00167 
00168 #endif  // _MSC_VER
00169 #endif  // _WIN32
00170 
00171 #ifndef PQXX_LIBEXPORT
00172 #define PQXX_LIBEXPORT
00173 #endif
00174 
00175 #ifndef PQXX_PRIVATE
00176 #define PQXX_PRIVATE
00177 #endif
00178 
00179 // Some compilers (well, VC) stumble over some required cases of "typename"
00180 #ifndef PQXX_TYPENAME
00181 #define PQXX_TYPENAME typename
00182 #endif
00183 
00184 #endif
00185 

Generated on Fri Jul 1 14:36:19 2005 for libpqxx by  doxygen 1.4.2