compiler-public.hxx

00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/compiler-public.hxx
00005  *
00006  *   DESCRIPTION
00007  *      Compiler deficiency workarounds for libpqxx clients
00008  *
00009  * Copyright (c) 2002-2015, 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 PQXX_HAVE_MOVE
00025 #include <utility>
00026 #define PQXX_MOVE(value) (std::move(value))
00027 #else
00028 #define PQXX_MOVE(value) (value)
00029 #endif
00030 
00031 #ifdef PQXX_HAVE_NOEXCEPT
00032 #define PQXX_NOEXCEPT noexcept
00033 #else
00034 #define PQXX_NOEXCEPT throw ()
00035 #endif
00036 
00037 #ifdef PQXX_HAVE_DELETED_OP
00038 #define PQXX_DELETED_OP =delete
00039 #else
00040 #define PQXX_DELETED_OP /* =delete */
00041 #endif
00042 
00043 #ifdef PQXX_HAVE_OVERRIDE
00044 #define PQXX_OVERRIDE override
00045 #else
00046 #define PQXX_OVERRIDE /*override*/
00047 #endif
00048 
00049 #ifdef PQXX_HAVE_FINAL
00050 #define PQXX_FINAL final
00051 #else
00052 #define PQXX_FINAL /*final*/
00053 #endif
00054 
00055 #ifdef _MSC_VER
00056 
00057 /* Work around a particularly pernicious and deliberate bug in Visual C++:
00058  * min() and max() are defined as macros, which can have some very nasty
00059  * consequences.  This compiler bug can be switched off by defining NOMINMAX.
00060  *
00061  * We don't like making choices for the user and defining environmental macros
00062  * of our own accord, but in this case it's the only way to compile without
00063  * incurring a significant risk of bugs--and there doesn't appear to be any
00064  * downside.  One wonders why this compiler wart is being maintained at all,
00065  * since the introduction of inline functions back in the 20th century.
00066  */
00067 #if defined(min) || defined(max)
00068 #error "Oops: min() and/or max() are defined as preprocessor macros.\
00069   Define NOMINMAX macro before including any system headers!"
00070 #endif
00071 
00072 #ifndef NOMINMAX
00073 #define NOMINMAX
00074 #endif
00075 
00076 // Suppress vtables on abstract classes.
00077 #define PQXX_NOVTABLE __declspec(novtable)
00078 
00079 #endif  // _MSC_VER
00080 
00081 
00082 // Workarounds & definitions that need to be included even in library's headers
00083 #include "pqxx/config-public-compiler.h"
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 #define PQXX_PRIVATE __hidden
00091 #endif  // __SUNPRO_CC
00092 
00093 
00094 #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_CONST)
00095 #define PQXX_CONST __attribute__ ((const))
00096 #else
00097 #define PQXX_CONST
00098 #endif
00099 
00100 #if defined(PQXX_HAVE_DEPRECATED)
00101 #define PQXX_DEPRECATED [[deprecated]]
00102 #elif defined(__GNUC__) && defined(PQXX_HAVE_GCC_DEPRECATED)
00103 #define PQXX_DEPRECATED __attribute__ ((deprecated))
00104 #else
00105 #define PQXX_DEPRECATED
00106 #endif
00107 
00108 #if defined(PQXX_HAVE_NORETURN)
00109 #define PQXX_NORETURN [[noreturn]]
00110 #elif defined(__GNUC__) && defined(PQXX_HAVE_GCC_NORETURN)
00111 #define PQXX_NORETURN __attribute__ ((noreturn))
00112 #elif defined(_MSC_VER)
00113 #define PQXX_NORETURN _declspec(noreturn)
00114 #else
00115 #define PQXX_NORETURN
00116 #endif
00117 
00118 #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_PURE)
00119 #define PQXX_PURE __attribute__ ((pure))
00120 #else
00121 #define PQXX_PURE
00122 #endif
00123 
00124 
00125 // Workarounds for Windows
00126 #ifdef _WIN32
00127 
00128 
00129 /* For now, export DLL symbols if _DLL is defined.  This is done automatically
00130  * by the compiler when linking to the dynamic version of the runtime library,
00131  * according to "gzh"
00132  */
00133 // TODO: Define custom macro to govern how libpqxx will be linked to client
00134 #if !defined(PQXX_LIBEXPORT) && defined(PQXX_SHARED)
00135 #define PQXX_LIBEXPORT __declspec(dllimport)
00136 #endif  // !PQXX_LIBEXPORT && PQXX_SHARED
00137 
00138 
00139 // Workarounds for Microsoft Visual C++
00140 #ifdef _MSC_VER
00141 
00142 #if _MSC_VER < 1600
00143 #error "If you're using Visual C++, you'll need at least the 2010 version."
00144 #endif  // _MSC_VER < 1600
00145 
00146 // Automatically link with the appropriate libpq (static or dynamic, debug or
00147 // release).  The default is to use the release DLL.  Define PQXX_PQ_STATIC to
00148 // link to a static version of libpq, and _DEBUG to link to a debug version.
00149 // The two may be combined.
00150 #if defined(PQXX_AUTOLINK)
00151 #if defined(PQXX_PQ_STATIC)
00152 #ifdef _DEBUG
00153 #pragma comment(lib, "libpqd")
00154 #else
00155 #pragma comment(lib, "libpq")
00156 #endif
00157 #else
00158 #ifdef _DEBUG
00159 #pragma comment(lib, "libpqddll")
00160 #else
00161 #pragma comment(lib, "libpqdll")
00162 #endif
00163 #endif
00164 #endif
00165 
00166 // If we're not compiling libpqxx itself, automatically link with the correct
00167 // libpqxx library.  To link with the libpqxx DLL, define PQXX_SHARED; the
00168 // default is to link with the static library.  This is also the recommended
00169 // practice.
00170 // Note that the preprocessor macro PQXX_INTERNAL is used to detect whether we
00171 // are compiling the libpqxx library itself. When you compile the library
00172 // yourself using your own project file, make sure to include this define.
00173 #if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
00174   #ifdef PQXX_SHARED
00175     #ifdef _DEBUG
00176       #pragma comment(lib, "libpqxxD")
00177     #else
00178       #pragma comment(lib, "libpqxx")
00179     #endif
00180   #else // !PQXX_SHARED
00181     #ifdef _DEBUG
00182       #pragma comment(lib, "libpqxx_staticD")
00183     #else
00184       #pragma comment(lib, "libpqxx_static")
00185     #endif
00186   #endif
00187 #endif
00188 
00189 #endif  // _MSC_VER
00190 #endif  // _WIN32
00191 
00192 #ifndef PQXX_LIBEXPORT
00193 #define PQXX_LIBEXPORT
00194 #endif
00195 
00196 #ifndef PQXX_PRIVATE
00197 #define PQXX_PRIVATE
00198 #endif
00199 
00200 // Some compilers (well, VC) stumble over some required cases of "typename"
00201 #ifndef PQXX_TYPENAME
00202 #define PQXX_TYPENAME typename
00203 #endif
00204 
00205 #ifndef PQXX_NOVTABLE
00206 #define PQXX_NOVTABLE
00207 #endif
00208 
00209 #endif
00210 

Generated on 17 Mar 2017 for libpqxx by  doxygen 1.6.1