Author: wyoung
Date: Thu Jan  3 08:25:21 2008
New Revision: 2066

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2066&view=rev
Log:
Moved more VC++ ifdef stuff into common.h, so only it references
_MSC_VER.  All other code uses macros defined in common.h that are named
after just the one feature we've made conditional.

Modified:
    trunk/lib/common.h
    trunk/lib/datetime.cpp
    trunk/lib/mystring.h
    trunk/lib/query.cpp
    trunk/lib/query.h

Modified: trunk/lib/common.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/common.h?rev=2066&r1=2065&r2=2066&view=diff
==============================================================================
--- trunk/lib/common.h (original)
+++ trunk/lib/common.h Thu Jan  3 08:25:21 2008
@@ -34,6 +34,17 @@
 #if !defined(DOXYGEN_IGNORE)
 // Doxygen will not generate documentation for the following stuff.
 
+// Enable SSQLS by default.  Turned off below on platforms where we
+// know it doesn't work.
+#define MYSQLPP_SSQLS_COMPATIBLE
+
+// For all platforms but Visual C++ 2003, the following macro is just
+// an alias for "*this".  It needs a more complicated definition on
+// VC++ 2003 to work around an error in the overloaded operator lookup
+// logic.  For an explanation of the problem, see:
+// 
http://groups.google.com/group/microsoft.public.vc.stl/browse_thread/thread/9a68d84644e64f15
+#define MYSQLPP_QUERY_THISPTR *this
+
 // Work out major platform-specific stuff here.
 #if defined(__WIN32__) || defined(_WIN32)
 #      define MYSQLPP_PLATFORM_WINDOWS
@@ -44,6 +55,18 @@
 
        // Stuff for Visual C++ only
 #      if defined(_MSC_VER)
+#              define MYSQLPP_PLATFORM_VISUAL_CPP
+#              if _MSC_VER < 1400
+#                      define MYSQLPP_QUERY_THISPTR 
dynamic_cast<std::ostream&>(*this)
+#                      undef MYSQLPP_SSQLS_COMPATIBLE
+#              elif !defined(_STLP_VERSION) && !defined(_STLP_VERSION_STR)
+                       // VC++ 2005 or newer and not using STLport, so #define
+                       // portability flags indicating features we can use from
+                       // the compiler's native RTL.
+#                      define MYSQLPP_HAVE_LOCALTIME_S
+#                      define MYSQLPP_HAVE_STD__NOINIT
+#              endif
+
                // Disable whining about using 'this' as a member initializer 
on VC++.
 #              pragma warning(disable: 4355)
                // Disable whining about implicit conversions to bool

Modified: trunk/lib/datetime.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/datetime.cpp?rev=2066&r1=2065&r2=2066&view=diff
==============================================================================
--- trunk/lib/datetime.cpp (original)
+++ trunk/lib/datetime.cpp Thu Jan  3 08:25:21 2008
@@ -219,19 +219,16 @@
 DateTime::DateTime(time_t t)
 {
        struct tm tm;
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(_STLP_VERSION) && \
-               !defined(_STLP_VERSION_STR)
-       // Use thread-safe localtime() replacement included with VS2005 and
-       // up, but only when using native RTL, not STLport.
+#if defined(MYSQLPP_HAVE_LOCALTIME_S)
+       // common.h detected localtime_s() from native RTL of VC++ 2005 and up
        localtime_s(&tm, &t);
 #elif defined(HAVE_LOCALTIME_R)
-       // Detected POSIX thread-safe localtime() replacement.
+       // autoconf detected POSIX's localtime_r() on this system
        localtime_r(&t, &tm);
 #else
        // No explicitly thread-safe localtime() replacement found.  This
        // may still be thread-safe, as some C libraries take special steps
-       // within localtime() to get thread safety.  For example, thread-
-       // local storage (TLS) in some Windows compilers.
+       // within localtime() to get thread safety, such as TLS.
        memcpy(&tm, localtime(&t), sizeof(tm));
 #endif
 

Modified: trunk/lib/mystring.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/mystring.h?rev=2066&r1=2065&r2=2066&view=diff
==============================================================================
--- trunk/lib/mystring.h (original)
+++ trunk/lib/mystring.h Thu Jan  3 08:25:21 2008
@@ -499,16 +499,13 @@
     TYPE num_;\
   };\
 
-#if defined(_MSC_VER)
+#if defined(MYSQLPP_PLATFORM_VISUAL_CPP)
+// Squish VC++ warning about "possible loss of data" for these conversions
 #      pragma warning(disable: 4244)
 #endif
 
        internal_convert_string_to_int(float, strtod)
        internal_convert_string_to_int(double, strtod)
-
-#if defined(_MSC_VER)
-#      pragma warning(default: 4244)
-#endif
 
 #undef internal_convert_string_to_int
 #define internal_convert_string_to_int(TYPE, FUNC) \
@@ -522,10 +519,6 @@
     TYPE num_;\
   };\
 
-#if defined(_MSC_VER)
-#      pragma warning(disable: 4244)
-#endif
-
        internal_convert_string_to_int(char, strtol)
        internal_convert_string_to_int(signed char, strtol)
        internal_convert_string_to_int(int, strtol)
@@ -537,12 +530,12 @@
        internal_convert_string_to_int(unsigned short int, strtoul)
        internal_convert_string_to_int(unsigned long int, strtoul)
 
-#if defined(_MSC_VER)
+#if defined(MYSQLPP_PLATFORM_VISUAL_CPP)
 #      pragma warning(default: 4244)
 #endif
 
 #if !defined(NO_LONG_LONGS)
-#if defined(_MSC_VER)
+#if defined(MYSQLPP_PLATFORM_VISUAL_CPP)
 // Handle 64-bit ints the VC++ way
 internal_convert_string_to_int(longlong, _strtoi64)
 internal_convert_string_to_int(ulonglong, _strtoui64)

Modified: trunk/lib/query.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=2066&r1=2065&r2=2066&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Thu Jan  3 08:25:21 2008
@@ -33,7 +33,7 @@
 namespace mysqlpp {
 
 Query::Query(Connection* c, bool te, const char* qstr) :
-#if defined(_MSC_VER) && !defined(_STLP_VERSION) && !defined(_STLP_VERSION_STR)
+#if defined(MYSQLPP_HAVE_STD__NOINIT)
 // prevents a double-init memory leak in native VC++ RTL (not STLport!)
 std::ostream(std::_Noinit), 
 #else
@@ -51,7 +51,7 @@
 }
 
 Query::Query(const Query& q) :
-#if defined(_MSC_VER) && !defined(_STLP_VERSION) && !defined(_STLP_VERSION_STR)
+#if defined(MYSQLPP_HAVE_STD__NOINIT)
 // ditto above
 std::ostream(std::_Noinit),
 #else

Modified: trunk/lib/query.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.h?rev=2066&r1=2065&r2=2066&view=diff
==============================================================================
--- trunk/lib/query.h (original)
+++ trunk/lib/query.h Thu Jan  3 08:25:21 2008
@@ -25,7 +25,7 @@
  USA
 ***********************************************************************/
 
-#ifndef MYSQLPP_QUERY_H
+#if !defined(MYSQLPP_QUERY_H)
 #define MYSQLPP_QUERY_H
 
 #include "common.h"
@@ -50,19 +50,6 @@
 #  if defined(HAVE_STD_SLIST) || defined(HAVE_GLOBAL_SLIST)
 #      include <slist>
 #  endif
-#endif
-
-/// \def MYSQLPP_QUERY_THISPTR
-/// \brief Helper macro used inside MySQL++ to work around a VC++ 2003 bug
-///
-/// This macro returns '*this', either directly or upcast to Query's
-/// base class to work around an error in the overloaded operator
-/// lookup logic in VC++ 2003.  For an explanation of the problem, see:
-/// 
http://groups.google.com/group/microsoft.public.vc.stl/browse_thread/thread/9a68d84644e64f15
-#if defined(_MSC_VER) && (_MSC_VER < 1400)
-#      define MYSQLPP_QUERY_THISPTR dynamic_cast<std::ostream&>(*this)
-#else
-#      define MYSQLPP_QUERY_THISPTR *this
 #endif
 
 namespace mysqlpp {
@@ -1014,5 +1001,5 @@
 
 } // end namespace mysqlpp
 
-#endif
-
+#endif // !defined(MYSQLPP_QUERY_H)
+


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to