| | | | Browse by category |
- I get an error when using RWZone::os(). The error is similar to the following:
error C2665: 'local' : none of the 2 overloads can
convert parameter 1 from type 'const class RWZone' - I get an unexpected result from RWZone::os().
Cause
- Wrong invocation of RWZone::os().
- Some platforms ignore the leftover garbage in a struct tm used in a call to 'mktime(struct tm*)' and others do not. For those platforms that use the garbage, the function returns an unexpected result.
Action
- There is a typographical error in our Tools.h++ documentation. Setting the DST based on the underlying OS using 'RWZone::local( RWZone::os() )' as stated in our documentation, will produce an error. The error was generated because RWZone::local() can not handle 'const RWZone&' value, returned by 'os()'. Instead, RWZone::local() accepts 'const RWZone* ' value.
The correct way to set the DST based on the OS is:
RWZone::local( &(RWZone::os()) )
instead of
RWZone::local(RWZone::os())
- This problem only affects Tools.h++ v7.1.0. One needs to identify the four(4) places in the file zone.cpp where struct tm objects are declared '(struct tm
;)' near line 93, 176, 252, and 325. Follow the statements with initializations to zero of those members not used in the call to 'mktime' separately.struct tm
;
.tm_sec = 0;
.tm_min = 0;
.tm_hour = 0;
.tm_mday = 0;
.tm_mon = 0;
.tm_year = 0;
.tm_wday = 0;
.tm_yday = 0;
.tm_isdst = 0; So, for zone.cpp line 93:
struct tm tmp;
//test 11AM of the last day of the incoming month
tmp.tm_year = currentYear;
tmp.tm_mon = month;
tmp.tm_mday = RWDate::daysInMonth[tmp.tm_mon];Changed to:
struct tm tmp;
//zero unnecessary members
tmp.tm_sec = 0;
tmp.tm_min = 0;
tmp.tm_hour = 0;
tmp.tm_wday = 0;
tmp.tm_yday = 0;
tmp.tm_isdst = 0;
//test 11AM of the last day of the incoming month
tmp.tm_year = currentYear;
tmp.tm_mon = month;
tmp.tm_mday = RWDate::daysInMonth[tmp.tm_mon];These modifications have been implemented in our next release of Tools.h++. You can download the modified zone.cpp file here: zone.cpp.tar.
Although at the present time MSVC 6.0 and Solaris 2.6-SunPro4.2 seem to be un-affected by a lack of initialization, to insure forward compatability, we recommend making this change on those platforms as well.
How to apply the zone.cpp.tar:
Untar or unzip zone.cpp.tar, go to your '/parts/tls0710u/source/src' directory if you are on Unix, or '/parts/tls0710w/source/src' directory if you are on Windows then replace your current zone.cpp file. Rebuild Tools.h++ to apply the modifications to your library.