#include time.h和 #include sys/time.h的区别

来源:互联网 发布:手机登陆电脑版淘宝 编辑:程序博客网 时间:2024/04/29 17:14

交叉编译情况下,两个文件的地址

/opt/gcc-4.1.2-glibc-2.4/arm-xscale-linux-gnu/arm-xscale-linux-gnu/include/time.h

 

/opt/gcc-4.1.2-glibc-2.4/arm-xscale-linux-gnu/arm-xscale-linux-gnu/include/sys/time.h

 

 

time.h 是ISO C99 标准日期时间头文件。

sys/time.h 是Linux 系统的日期时间头文件。

sys/time.h 通常会包含include time.h

 

 

编写的代码如果是平台无关的,则需要在代码里include time.h. 

但这样的话,使用time_t等数据结构的话可能需要手动

#define __need_time_t

#define __need_timespec

 

通常如果代码可以是平台相关的,则只需要include sys/time.h

 

End.