简体   繁体   English

C ++ - 包括unistd.h:为什么不cunistd?

[英]C++ - include unistd.h: why not cunistd?

It's said that when including C header files in C++, the ".h" suffix should be removed and then add "c" at the beginning. 据说当在C ++中包含C头文件时,应该删除“.h”后缀,然后在开头添加“c”。 For example, #include <cstdio> instead of #include <stdio.h> . 例如, #include <cstdio>而不是#include <stdio.h> But when I use sleep() in my code, #include <cunistd> does not work, but #include <unistd.h> works. 但是当我在代码中使用sleep()时, #include <cunistd>不起作用,但#include <unistd.h>有效。 Why not <cunistd> ? 为什么不<cunistd>

您的算法对于大多数(所有?)标准C头是正确的,但unistd.h不是标准C的一部分,因此标准C ++反过来不包括它与其他c...头。

Because unistd.h never was part of the C language. 因为unistd.h从未成为C语言的一部分。 It is part of the Operating System. 它是操作系统的一部分。

<unistd.h> ,代表unix标准标题,名称说明了一切。

unistd.h不是标准C的一部分。标准C ++ lib不包含其他c标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM