tags:

views:

153

answers:

2

Is there any compiler option to make time_t 64-bit in Solaris 5.8 in forte compiler. I need to develop library in 32-bit and I cannot change it to 64-bit as it effects existing client applications.

+2  A: 

Short answer is no, there is no option in the compiler to make time_t a 64bit value in a 32bit application. It was extended to a 64bit value for 64bit applications as this seemed like a good change to make, but for compliance with all the various standards, it has to be kept as a signed 32bit value for 32bit applications.

If you want to use a 64bit value to represent time, then you will have to make sure that any values returned to the existing client applications do not overflow when returned. If they do overflow then you would need to support specifying this to the client application, and understand how they would deal with the values, which is all part of the API to the library.

Petesh
+3  A: 

Sun does not (yet) provide any compiler option for this, other than compiling for 64-bit. If you simply need to be able to handle post-2038 dates in your 32-bit application (e.g. for a 30-year mortgage calculation) and do not need such dates in the Solaris kernel (e.g. current time, file timestamps), then there are packages that you can use within your application to handle such dates. For example y2038 is a simple package that provides a 64-bit time_t-like type and the corresponding replacements for localtime(), gmtime(), ctime(), etc. If you are not tied to the POSIX interfaces you could instead use something like libtai, which also handles leap seconds.

mark4o