Difference between unistd.h and sys/types.h in linux

前端 未结 1 1882
一整个雨季
一整个雨季 2021-02-15 17:20

When I have searched for the header unistd.h, in The Open Group, I found that it contains the standard symbolic constants & types and for sys/types.h it said for data types.

1条回答
  •  深忆病人
    2021-02-15 17:49

    The division of the POSIX and C header in fine grained files probably comes from the old days when compilation might take a long time, and adding unnecesary header files made the time longer.

    If you only need the OS types, say for the prototypes of your functions, then just #include . However if you need the function definitions, then you #include or any of the other system headers, as needed.

    Naturally there are types that are in both headers, as you cannot declare some functions without their necessary types.

    But these different declarations of the same type are guaranteed to be the same, so there is no problem if you include both.

    0 讨论(0)
提交回复
热议问题