现在的位置: 首页 > 综合 > 正文

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

2013年10月12日 ⁄ 综合 ⁄ 共 441字 ⁄ 字号 评论关闭

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

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

/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.

抱歉!评论已关闭.