Strange wxGTK behavior (was Re: wxDateTime (time_t) Save/Load)

Armel armelasselin at hotmail.com
Sat Apr 19 12:24:40 PDT 2008




"Igor Korot" <ikorot at earthlink.net> a écrit dans le message de news: 
mailman.19.1208470677.17602.wx-users at lists.wxwidgets.org...
> Hi, ALL,
> I have following code in my program:
>
> wxDateTime t = Now();
> #if wxUSE_STD_IOSTREAM
> (wxSTD ostream) stream << t.GetTicks();
> #endif
this cast is a bit strange... from a pure C++ point of view, it means 'build 
a wxSTD ostream' __value__ out of 'stream' and do '<< t.GetTicks( )' on it, 
then get rid of that 'wxSTD ostream' temporary value. could it be the 
problem?

> The stream is based on the file on hard drive.
> When I look at the file I don't see anything saved.
>
> What is the problem? Am I using this wrong?
>
> Thank you.
Hope it helps

Armel
>
>
> -----Original Message-----
>>From: Hans Harmon <hans_harmon at yahoo.com>
>>Sent: Mar 19, 2008 11:00 AM
>>To: wx-users at lists.wxwidgets.org
>>Subject: Re: wxDateTime (time_t) Save/Load
>>
>>Yes that should work.
>>Typically I use typedef's for the 64 bit integers.  I
>>do embedded as well as desktop code.  So it looks more
>>like (needs endian checks):
>>
>>time_t now;
>>
>>#ifdef __HAS_INT64__
>>sint64 value;
>>#else
>>sint32 value;
>>sint32 zero;
>>
>>zero = 0;
>>#endif
>>
>>value = (sint64) now;
>>#ifdef __HAS_INT64__
>>write ( value, sizeof ( sint64 ));
>>#else
>>write ( zero, sizeof ( sint32 ));
>>write ( value, sizeof ( sint32 ));
>>#endif
>>
>>
>>So #if's because I am never sure of what hardware I am
>>on, but the idea is the same.
>>
>>
>>Hans
>>
>>--- Igor Korot <ikorot at earthlink.net> wrote:
>>
>>
>>---------------------------------
>>body{font-family:
>>Geneva,Arial,Helvetica,sans-serif;font-size:9pt;background-color:
>>#ffffff;color: black;}
>>Hans,
>>
>>You mean something like this:
>>
>>
>>
>>time_t now;
>>
>>UInt 64 value;
>>
>>value = wxDynamicCast( now, UInt64 );
>>
>>if( value )
>>
>>     // 64-bit save
>>
>>else
>>
>>    // 32-bit save
>>
>>
>>
>>Thank you.
>>
>>
>>
>>-----Original Message----- 
>>From: Hans Harmon
>>Sent: Mar 18, 2008 6:05 AM
>>To: wx-users at lists.wxwidgets.org
>>Subject: Re: wxDateTime (time_t) Save/Load
>>
>>time_t is changes, depending on OS and compilier.
>>This makes saving it very frustrating.  I had code
>>that worked in MSVC 2003 only to have it break in 2005
>>because time_t went from a 32 bit to 64.  My
>>recommendation is to cast it to 64 bit if available,
>>and always write it as such.  If the system does not
>>have 64 bit integers then just write a blank 32 bit as
>>a spacer so that it can be read in wherever you take
>>the code.
>>
>>Hans
>>
>>
>>Igor Korot <ikorot at earthlink.net> wrote:Hi, ALL,
>>I just looked at the wxDataOutputStream. It has only
>>Write8/16/32/64 functions.
>>However, at least on MSW time_t is 'long integer'.
>>
>>1. Is it safe to assume time_t is 'long integer' on
>>all platform?
>>2. Does this mean I need to make my own function?
>>
>>Thank you.
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail:
>>wx-users-unsubscribe at lists.wxwidgets.org
>>For additional commands, e-mail:
>>wx-users-help at lists.wxwidgets.org
>>
>>
>>
>>
>>---------------------------------
>>Be a better friend, newshound, and know-it-all with
>>Yahoo! Mobile. Try it
>>now.---------------------------------------------------------------------To
>>unsubscribe, e-mail:
>>wx-users-unsubscribe at lists.wxwidgets.orgFor additional
>>commands, e-mail: wx-users-help at lists.wxwidgets.org
>>
>>
>>
>> 
>> ____________________________________________________________________________________
>>Looking for last minute shopping deals?
>>Find them fast with Yahoo! Search. 
>>http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
>>For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>>
> 




More information about the wx-users mailing list