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

C++C

C++ Problem Overview


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++ Solutions


Solution 1 - 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.

Solution 2 - C++

Because unistd.h never was part of the C language. It is part of the Operating System.

Solution 3 - C++

<unistd.h> , stands for unix standard header ,the name says it all.

Solution 4 - C++

unistd.h is not part of standard C. Standard C++ lib doesn't include it with the other c headers.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCDTView Question on Stackoverflow
Solution 1 - C++Carl NorumView Answer on Stackoverflow
Solution 2 - C++comocomocomocomoView Answer on Stackoverflow
Solution 3 - C++Barath RavikumarView Answer on Stackoverflow
Solution 4 - C++babttzView Answer on Stackoverflow