I do not have any definite answer.
But time_t has a wiki page!!! http://en.wikipedia.org/wiki/Time_t
The standard does not specify the type. Instead there is:
double difftime(time_t time1, time_t time0);
Excerpt from the man:
On a POSIX system, time_t is an arithmetic type, and one could just
define
#define difftime(t1,t0) (double)(t1 - t0)
when the possible overflow in the subtraction is not a concern. On
^^^^^^^^^^^^^^^^^^
other systems, the data type time_t might use some other encoding where
subtraction doesn't work directly.
My understanding is that it is not safe to rely on the signedness of time_t.
But we probably increase our level our bug-compatibility if we use the same as
GNU lib C.
My only concern: is this going to break anything else?
Thoughts?
--
Erven.
Kevin Williams a écrit :
> Hi all,
>
> I have noticed that gcc4cli declares time_t as an 'unsigned long'.
> The GNU C lib declares it as 'signed long'.
>
> This difference causes getimeofday to report incorrect numbers when
> using the common function.....
>
> double time = (endTime.tv_sec - startTime.tv_sec) + ( (endTime.tv_usec
> - startTime.tv_usec) / 1.e6);
>
>
> was time_t declared as unsigned long for a reason?
> If not can we change it to signed?
>
> Thanks,
> Kevin
|