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 // Workarounds for Microsoft Visual C++
00125 #ifdef _MSC_VER
00126 
00127 #if _MSC_VER < 1300
00128 #error If you're using Visual C++, you'll need at least version 7 (VC.NET)
00129 #elif _MSC_VER < 1310
00130 // Workarounds for pre-2003 Visual C++.NET
00131 #undef PQXX_HAVE_REVERSE_ITERATOR
00132 #define PQXX_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION
00133 #define PQXX_TYPENAME
00134 #endif  // _MSC_VER < 1310
00135 
00136 #pragma warning (disable: 4290)
00137 #pragma warning (disable: 4355)
00138 #pragma warning (disable: 4786)
00139 #pragma warning (disable: 4251 4275 4273)
00140 #pragma comment(lib, "libpqdll")
00141 #if !defined(PQXX_LIBEXPORT) && !defined(_LIB)
00142 #define PQXX_LIBEXPORT __declspec(dllimport)
00143 #endif  // PQXX_LIBEXPORT _LIB
00144 
00146 
00158 #define PQXX_QUIET_DESTRUCTORS
00159 
00160 #endif  // _MSC_VER
00161 #endif  // _WIN32
00162 
00163 // Used for Windows DLL
00164 #ifndef PQXX_LIBEXPORT
00165 #define PQXX_LIBEXPORT
00166 #endif
00167 
00168 // Some compilers (well, VC) stumble over some required cases of "typename"
00169 #ifndef PQXX_TYPENAME
00170 #define PQXX_TYPENAME typename
00171 #endif
00172 
00173 #endif
00174 

Generated on Sat Mar 19 18:42:42 2005 for libpqxx by  doxygen 1.4.1