How can adding a header increase portability? (sys/time.h)

时光总嘲笑我的痴心妄想 提交于 2019-12-02 03:36:42

In general, it was not uncommon in the early days of C for you to have to manually include header file A before header file B. Maybe an early version of the preprocessor couldn't do nested includes, or maybe it was just stylistic (manpages would often directly include the header files for relevant structures).

"These days", sys/resource.h must either include sys/time.h or repeat the definition of struct timeval, but not every system follows the standard completely.

It's because the BSD's require it:

FreeBSD and OpenBSD need sys/time.h, not just time.h, before sys/resource.h.

See this page on UNIX Portability for details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!