What is time_t ultimately a typedef to?

后端 未结 10 2064
陌清茗
陌清茗 2020-11-22 08:34

I searched my Linux box and saw this typedef:

typedef __time_t time_t;

But I could not find the __time_t definition.

10条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 09:19

    time_t is of type long int on 64 bit machines, else it is long long int.

    You could verify this in these header files:

    time.h: /usr/include
    types.h and typesizes.h: /usr/include/x86_64-linux-gnu/bits

    (The statements below are not one after another. They could be found in the resp. header file using Ctrl+f search.)

    1)In time.h

    typedef __time_t time_t;
    

    2)In types.h

    # define __STD_TYPE     typedef  
    __STD_TYPE __TIME_T_TYPE __time_t;  
    

    3)In typesizes.h

    #define __TIME_T_TYPE       __SYSCALL_SLONG_TYPE  
    #if defined __x86_64__ && defined __ILP32__  
    # define __SYSCALL_SLONG_TYPE   __SQUAD_TYPE  
    #else
    # define __SYSCALL_SLONG_TYPE   __SLONGWORD_TYPE
    #endif  
    

    4) Again in types.h

    #define __SLONGWORD_TYPE    long int
    #if __WORDSIZE == 32
    # define __SQUAD_TYPE       __quad_t
    #elif __WORDSIZE == 64
    # define __SQUAD_TYPE       long int  
    
    #if __WORDSIZE == 64
    typedef long int __quad_t;  
    #else
    __extension__ typedef long long int __quad_t;
    

提交回复
热议问题