List:MySQL++« Previous MessageNext Message »
From:Joel Fielder Date:January 10 2007 4:20pm
Subject:RE: v2.2 release plan
View as plain text  
Hello,

I tested the latest snapshot of the library with Mingw.

There is no localtime_r function present in Mingw so datetime.cpp [195]
does not compile.  I commented out the line to check the remainder of
the build and it was otherwise fine: 0 warnings, 0 errors.

I think there's a straightforward fix; according to the following
sources, localtime on MinGW is thread-safe so we should be able to shift
calls to localtime_r onto localtime:

http://www.mingw.org/docs.shtml#win32api
"Mingw uses the runtime libraries distributed with the OS."

Specifically, in the readme file for mingw-runtime-3.11 source:
"Mingw32 programs use CRTDLL.DLL to provide their C run time library
functions, and CRTDLL.DLL is supplied with all current Win32 platforms."

http://msdn2.microsoft.com/en-us/library/bf12f0hc(VS.80).aspx
"Both the 32-bit and 64-bit versions of gmtime, mktime, mkgmtime, and
localtime all use a single tm structure per thread for the conversion.
Each call to one of these routines destroys the result of the previous
call."

By this I read that Mingw is simply delegating localtime straight into
the standard library shipped on all versions of Windows, meaning that
for Mingw, we can do the same as in pthreads:

#define localtime_r( _clock, _result ) \
        ( *(_result) = *localtime( (_clock) ), \
          (_result) )

This can be surrounded by #if defined __MINGW32_VERSION and #endif in an
appropriate place in platform.h.  Perhaps it would be better to modify
datetime.cpp as localtime_r is not used anywhere else within mysqlpp and
some users may have their own workarounds for the localtime_r issue
elsewhere in their header files.

And maybe a slightly different macro (or even an inline function) would
be more suitable as the pthreads macro above leads to a warning (at
least with -Wall anyway): right-hand operand of comma has no effect.

Or use boost's date and time library.

Joel.

Thread
v2.2 release planWarren Young9 Jan
  • RE: v2.2 release planJoel Fielder10 Jan
    • RE: v2.2 release planMatt Dargavel10 Jan
      • RE: v2.2 release planMatt Dargavel10 Jan
        • Re: v2.2 release planPedro Lamarão10 Jan
    • Re: v2.2 release planWarren Young12 Jan
      • Re: v2.2 release planJoel Fielder12 Jan
        • Re: v2.2 release planWarren Young12 Jan
          • RE: v2.2 release planMatt Dargavel12 Jan
            • Re: v2.2 release planWarren Young12 Jan
      • MySQL++ and BoostPedro Lamarão12 Jan
        • Re: MySQL++ and BoostWarren Young12 Jan
          • Re: MySQL++ and BoostPedro Lamarão12 Jan
            • Re: MySQL++ and BoostWarren Young12 Jan
              • Re: MySQL++ and BoostChris Frey12 Jan
                • Re: MySQL++ and BoostWarren Young12 Jan
RE: MySQL++ and BoostJim Wallace12 Jan
  • Re: MySQL++ and BoostWarren Young12 Jan
  • RE: MySQL++ and BoostSteve Orton12 Jan
RE: MySQL++ and BoostJim Wallace12 Jan