C ++ - include unistd.h:为什么不cunistd? [英] C++ - include unistd.h: why not cunistd?
问题描述
据说,当在C ++中包含C头文件时,应该删除.h后缀,然后在开头添加c。例如, #include< cstdio>
而不是 #include< stdio.h>
。但是当我在代码中使用 sleep()
时, #include< cunistd>
c $ c> #include< unistd.h> 工程。为什么< 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. For example, #include <cstdio>
instead of #include <stdio.h>
. But when I use sleep()
in my code, #include <cunistd>
does not work, but #include <unistd.h>
works. Why not <cunistd>
?
推荐答案
大多数(所有?)标准C头文件,但 unistd.h
不是标准C的一部分,因此标准C ++不包括其他 c ...
头。
Your algorithm is correct for most (all?) standard C headers, but unistd.h
is not part of standard C so standard C++ in turn doesn't include it with the other c...
headers.
这篇关于C ++ - include unistd.h:为什么不cunistd?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!