I have some code which is built both on Windows and Linux. Linux at this point is always 32bit but Windows is 32 and 64bit. Windows wants to have time_t be 64 bit and Linu
My favourite way of handling with the issue is:
time_t
and use the redefined time_t
everywhere instead of unsigned long long
etc.:#define time_t intmax_t /* Or unsigned long long int, int64_t etc. */
strftime
every time that you want to convert the timestamp to a string instead of relying on format strings. Format strings are unreliable, and overflow/underflow errors in format strings are often painful to debug, and hard to find while doing static analysis.A time will come however when most of the Unix system and compilers out there must converge towards a 64-bit time_t
. At least, I hope that that time comes before 2038.