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 // Workarounds & definitions that need to be included even in library's headers
00021 #include "pqxx/config-public-compiler.h"
00022 
00023 
00024 #ifdef PQXX_BROKEN_ITERATOR
00025 #include <cstddef>
00026 #include <cstdlib>
00028 
00036 namespace PGSTD
00037 {
00039 template<typename Cat, 
00040          typename T, 
00041          typename Dist, 
00042          typename Ptr=T*,
00043          typename Ref=T&> struct iterator
00044 {
00045   typedef Cat iterator_category;
00046   typedef T value_type;
00047   typedef Dist difference_type;
00048   typedef Ptr pointer;
00049   typedef Ref reference;
00050 };
00051 }
00052 #else
00053 #include <iterator>
00054 #endif // PQXX_BROKEN_ITERATOR
00055 
00056 #ifndef PQXX_HAVE_CHAR_TRAITS
00057 #include <cstddef>
00058 namespace PGSTD
00059 {
00061 template<typename CHAR> struct char_traits {};
00063 template<> struct char_traits<char>
00064 {
00065   typedef int int_type;
00066   typedef size_t pos_type;
00067   typedef long off_type;
00068   typedef char char_type;
00069 
00070   static int_type eof() { return -1; }
00071 };
00073 template<> struct char_traits<unsigned char>
00074 {
00075   typedef int int_type;
00076   typedef size_t pos_type;
00077   typedef long off_type;
00078   typedef unsigned char char_type;
00079 
00080   static int_type eof() { return -1; }
00081 };
00082 }
00083 #endif
00084 
00085 // Workarounds for SUN Workshop 6
00086 #if defined(__SUNPRO_CC)
00087 #if __SUNPRO_CC_COMPAT < 5
00088 #error "This compiler version is not capable of building libpqxx."
00089 #endif  // __SUNPRO_CC_COMPAT < 5
00090 
00091 #define PQXX_BROKEN_MEMBER_TEMPLATE_DEFAULT_ARG
00092 
00093 #endif  // __SUNPRO_CC
00094 
00095 
00096 // Workarounds for Compaq C++ for Alpha
00097 #if defined(__DECCXX_VER)
00098 #define __USE_STD_IOSTREAM
00099 #endif  // __DECCXX_VER
00100 
00101 
00102 // Workarounds for Windows
00103 #ifdef _WIN32
00104 
00105 // Workarounds for Microsoft Visual C++
00106 #ifdef _MSC_VER
00107 #if _MSC_VER < 1300
00108 #error If you're using Visual C++, you'll need at least version 7 (VC.NET)
00109 #endif  // _MSC_VER < 1300
00110 
00111 // Workarounds for Visual C++.NET (2003 version does seem to work)
00112 #if _MSC_VER < 1310
00113 #undef PQXX_HAVE_REVERSE_ITERATOR
00114 #define PQXX_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION
00115 #define PQXX_TYPENAME
00116 #endif  // _MSC_VER < 1310
00117 #pragma warning (disable: 4290)
00118 #pragma warning (disable: 4355)
00119 #pragma warning (disable: 4786)
00120 #pragma warning (disable: 4251 4275 4273)
00121 #pragma comment(lib, "libpqdll")
00122 #if !defined(PQXX_LIBEXPORT) && !defined(_LIB)
00123 #define PQXX_LIBEXPORT __declspec(dllimport)
00124 #endif  // PQXX_LIBEXPORT _LIB
00125 
00126 /* Work around a particularly pernicious and deliberate bug in Visual C++:
00127  * min() and max() are defined as macros, which can have some very nasty
00128  * consequences.  This compiler bug can be switched off by defining NOMINMAX.
00129  *
00130  * We don't like making choices for the user and defining environmental macros
00131  * of our own accord, but in this case it's the only way to compile without
00132  * incurring a significant risk of bugs--and there doesn't appear to be any
00133  * downside.  One wonders why this compiler wart is being maintained at all,
00134  * since the introduction of inline functions back in the 20th century.
00135  */
00136 #ifdef _MSC_VER
00137 #if defined(min) || defined(max)
00138 #error "Oops: min() and/or max() are defined as preprocessor macros.\
00139   Define NOMINMAX macro before including any system headers!"
00140 #endif
00141 #define NOMINMAX
00142 #endif
00143 
00144 
00145 #endif  // _MSC_VER
00146 #endif  // _WIN32
00147 
00148 // Used for Windows DLL
00149 #ifndef PQXX_LIBEXPORT
00150 #define PQXX_LIBEXPORT
00151 #endif
00152 
00153 // Some compilers (well, VC) stumble over some required cases of "typename"
00154 #ifndef PQXX_TYPENAME
00155 #define PQXX_TYPENAME typename
00156 #endif
00157 
00158 #endif
00159 

Generated on Tue Feb 8 09:17:14 2005 for libpqxx by  doxygen 1.4.1