Hello,

well this macros had one typo and an illegal assignment.

This code should work, but of course you can use memset instead of
assigning to __tm_zero, too.

#include <time.h>

static struct tm __tm_zero;

#define localtime_r_1(_Time, _Tm)       ({ struct tm *___tmp_tm =      \
                                               localtime((_Time));     \
                                               if (___tmp_tm)          \
                                                 *(_Tm) = *___tmp_tm;  \
                                               else *(_Tm) = __tm_zero;
                                               ___tmp_tm;      })

#define localtime_r_2(_Time, _Tm) (localtime ((_Time)) ? *(_Tm) = \
*localtime ((_Time)),(_Tm) : __tm_zero)

int main(void) {
       time_t t1;
       struct tm tm1;
       localtime_r_1(&t1, &tm1);
       localtime_r_2(&t1, &tm1);
}

Cheers,
Kai

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to