On Visual studio I can force use of 32-bit time_t
by declaring _USE_32BIT_TIME_T
. Is there a similar equivalent for gcc? or is it always 32-bit or is it always 64-bit?
Asked
Active
Viewed 7,211 times
4

phuclv
- 37,963
- 15
- 156
- 475

AppDeveloper
- 927
- 11
- 21
-
32-bit `time_t` is a bad idea. 64-bit `time_t` should be used instead, even in 32-bit Linux: [Is there any way to get 64-bit `time_t` in 32-bit programs in Linux?](https://stackoverflow.com/q/14361651/995714) – phuclv Jul 08 '23 at 01:59
1 Answers
7
The time_t
type is not defined by gcc but rather by system library. On Linux, this is glibc, and it defines time_t
in time.h
header:
typedef __time_t time_t;
which is in turn defined in bits/types.h
:
__STD_TYPE __TIME_T_TYPE __time_t;
(__STD_TYPE
definition is not interesting),
__TIME_T_TYPE
is defined in bits/typesizes.h
:
#define __TIME_T_TYPE __SLONGWORD_TYPE
which is in turn defined in bits/types.h
:
#define __SLONGWORD_TYPE long int
which is 32 bits on 32 bits system, 64 bits on 64 bits system. All these definitions are unconditional, so, no _USE_32BIT_TIME_T
equivalent on glibc.

Laurynas Biveinis
- 10,547
- 4
- 53
- 66
-
so as long as I compiled on 32 bit platform it should be fine. any info for gcc on Mac? – AppDeveloper Apr 14 '10 at 23:31
-
@SnapConfig.com You can check Mac headers the same way I did on Linux – Laurynas Biveinis Apr 15 '10 at 04:16