| www.delorie.com/djgpp/bugs/show.cgi | search |
tzname[] has an invalid values which produces a "General Protection Fault" independent from was tzset() called or not. Also daylight, timezone, altzone are absent but they are UNIX-standard variables and used in several programs.
/*
Compile and link this module to your program
if you want to use tzname[] without getting a SIGSEGV.
*/
#include <time.h>
static void __attribute__ ((constructor)) Set_tzname(void)
{
time_t ti;
struct tm* tm;
time(&ti);
tzset();
tm = gmtime(&ti);
tm->tm_mon = 1;
tm->tm_mday = 1;
ti = mktime(tm);
tm = localtime(&ti);
tzname[0] = tm->tm_zone;
tm = gmtime(&ti);
tm->tm_mon = 7;
tm->tm_mday = 1;
ti = mktime(tm);
tm = localtime(&ti);
tzname[1] = tm->tm_zone;
}Upgrade to v2.02, there are no GPFs there.
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2010 by DJ Delorie | Updated Jul 2010 |