FLTK logo

STR #1079

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]

STR #1079

Application:FLTK Library
Status:1 - Closed w/Resolution
Priority:2 - Low, e.g. a documentation error or undocumented side-effect
Scope:2 - Specific to an operating system
Subsystem:WIN32
Summary:Problems with localtime
Version:1.1-current
Created By:rtrocca
Assigned To:mike
Fix Version:1.1-current (SVN: v4701)
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text  
 
#1 rtrocca
06:05 Nov 13, 2005
I've found this problem working with Visual C ++ 2005 Express Edition (release version) on Win2Ksp4 (AMD Athlon 32bit) and the latest Platform SDK from Microsoft.

When compiling in debug mode an application using the Fl_Clock widget it crashes with the message:
Debug Assertion Failed!
Program: j:\....\test\formsd.exe
File: loctim64.c
Line: 78

Expression (*ptime <= _MAX_TIME64_T)

The problem arises because of localtime:

void Fl_Clock_Output::value(ulong v) {
  value_ = v;
  struct tm *timeofday;
  timeofday = localtime((const time_t *)&v);
  value(timeofday->tm_hour, timeofday->tm_min, timeofday->tm_sec);
}
localtime wants a variable that is an unsigned(?) _int64...
Therefore I tried to change enumerations.H
typedef unsigned __in64 ulong;

I had to change fl_dnd_win32.cxx
STDMETHODIMP GiveFeedback( ulong ) { return DRAGDROP_S_USEDEFAULTCURSORS; }
use DWORD instead of ulong


In this way everything *SEEMS* to work, or, at least Fl_Clock does not crash...

I fear however that this fix can break something else.
FLTK Gurus... help ;-)
 
 
#2 rtrocca
07:27 Nov 16, 2005
I tried FLTK 2, and the same localtime bug is present there.
I still did not try to fix it, even if I presume that it should work in the same way.

Riccardo
 
 
#3 d.zimmer
14:40 Dec 07, 2005
This would be a fix without side-effects:

void Fl_Clock_Output::value(ulong v) {
  value_ = v;
  struct tm *timeofday;
  time_t t = (time_t)v;
  timeofday = localtime(&t);
#if 0
  timeofday = localtime((const time_t *)&v);
#endif
  value(timeofday->tm_hour, timeofday->tm_min, timeofday->tm_sec);
}

From MSDN:

"In Visual C++ 2005, localtime is an inline function which evaluates to _localtime64, and time_t is equivalent to __time64_t. If you need to force the compiler to interpret time_t as the old 32-bit time_t, you can define _USE_32BIT_TIME_T. Doing this will cause localtime to evaluate to _localtime32. This is not recommended because your application may fail after January 19, 2038, and it is not allowed on 64-bit platforms."

Microsoft really should have left localtime alone for WIN32, and only changed it for WIN64.

Don.
 
 
#4 mike
16:34 Dec 13, 2005
Fixed in Subversion repository.  
     

Return to Bugs & Features ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.