Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c

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>?

like image 486
CDT Avatar asked Mar 11 '13 05:03

CDT


People also ask

Why do we include Unistd H?

In the C and C++ programming languages, unistd. h is the name of the header file that provides access to the POSIX operating system API. It is defined by the POSIX. 1 standard, the base of the Single Unix Specification, and should therefore be available in any POSIX-compliant operating system and compiler.

Is Unistd H standard library?

No, unistd. h and fcntl. h , etc are not part of standard C.

Does Windows have Unistd H?

h is a built-in header file in Linux/Unix system, which contains function prototypes of many system call, such as srandom and random function, write function and getpid . The "uni" part in unistd stands for "UNIX", meaning that you won't find it on a Windows system.

How do I install Unistd h in Windows?

The function fork is not a standard Win32 function and I'm not sure if it is available in 3rd party libraries for windows. If you write #include <unistd. h>, you must put that file in "include" folder of visual studio (Installation directory).


1 Answers

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.

like image 84
Carl Norum Avatar answered Oct 10 '22 19:10

Carl Norum