# compiler-internal.hxx

    00001 /*-------------------------------------------------------------------------
    00002  *
    00003  *   FILE
    00004  *      pqxx/compiler-internal.hxx
    00005  *
    00006  *   DESCRIPTION
    00007  *      Compiler deficiency workarounds for compiling libpqxx itself.
    00008  *      DO NOT INCLUDE THIS FILE when building client programs.
    00009  *
    00010  * Copyright (c) 2002-2008, Jeroen T. Vermeulen <jtv@xs4all.nl>
    00011  *
    00012  * See COPYING for copyright license.  If you did not receive a file called
    00013  * COPYING with this source code, please notify the distributor of this mistake,
    00014  * or contact the author.
    00015  *
    00016  *-------------------------------------------------------------------------
    00017  */
    00018 #ifndef PQXX_H_COMPILER_INTERNAL
    00019 #define PQXX_H_COMPILER_INTERNAL
    00020
    00021
    00022 // Workarounds & definitions needed to compile libpqxx into a library
    00023 #include "pqxx/config-internal-compiler.h"
    00024
    00025 // Library-private configuration related to libpq version
    00026 #include "pqxx/config-internal-libpq.h"
    00027
    00028 #ifdef _WIN32
    00029
    00030 #ifdef PQXX_SHARED
    00031 #undef  PQXX_LIBEXPORT
    00032 #define PQXX_LIBEXPORT  __declspec(dllexport)
    00033 // TODO: Does Windows have a way to "unexport" a symbol in an exported class?
    00034 #define PQXX_PRIVATE    __declspec()
    00035 #endif  // PQXX_SHARED
    00036
    00037 #ifdef _MSC_VER
    00038 #pragma warning (disable: 4251 4275 4273)
    00039 #pragma warning (disable: 4258) // Complains that for-scope usage is correct
    00040 #pragma warning (disable: 4290)
    00041 #pragma warning (disable: 4355)
    00042 #pragma warning (disable: 4786)
    00043 #pragma warning (disable: 4800) // Performance warning for boolean conversions
    00044 #endif
    00045
    00046 #elif defined(__GNUC__) && defined(PQXX_HAVE_GCC_VISIBILITY)    // !_WIN32
    00047
    00048 #define PQXX_LIBEXPORT __attribute__ ((visibility("default")))
    00049 #define PQXX_PRIVATE __attribute__ ((visibility("hidden")))
    00050
    00051 #endif  // __GNUC__ && PQXX_HAVE_GCC_VISIBILITY
    00052
    00053
    00054 #include "pqxx/compiler-public.hxx"
    00055
    00056 #ifdef PQXX_HAVE_LIMITS
    00057 #include <limits>
    00058 #else // PQXX_HAVE_LIMITS
    00059 #include <climits>
    00060 namespace PGSTD
    00061 {
    00063 template<typename T> struct numeric_limits
    00064 {
    00065   static T max() throw ();
    00066   static T min() throw ();
    00067 };
    00068 template<> inline long numeric_limits<long>::max() throw () {return LONG_MAX;}
    00069 template<> inline long numeric_limits<long>::min() throw () {return LONG_MIN;}
    00070 }
    00071 #endif // PQXX_HAVE_LIMITS
    00072
    00073
    00074 namespace pqxx
    00075 {
    00076 namespace internal
    00077 {
    00079 template<typename T> inline ptrdiff_t distance(T first, T last)
    00080 {
    00081 #ifdef PQXX_HAVE_DISTANCE
    00082   return PGSTD::distance(first, last);
    00083 #else
    00084   // Naive implementation.  All we really need for now.
    00085   ptrdiff_t d;
    00086   for (d=0; first != last; ++d) ++first;
    00087   return d;
    00088 #endif
    00089 }
    00090 }
    00091 }
    00092
    00093 #endif
    00094