Where is <unistd.h> ?

I need to download the header file <unistd.h>. I cannot find one on the internet, also I copy and pasted code from here into a new header file I named unistd.h (within Visual Studio), and it still reports that unistd.h does not exist.

Does anyone have the file, or knows the code?

http://www.koders.com/c/fid6D72DEF53B5D7C161C7FE38E02011A2BC466D119.aspx
This header file is not part of C or C++. It is provided by POSIX-compatible systems http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

Copying it from a POSIX system into a Visual Studio project won't do any good. What do you "need to download" it for?
Last edited on
I'm converting a project of mine from Windows-only to multi-platform compatability. In essence, I'm using the Windows Sleep function in a project, and I require the project to be compatible with Mac, Linux etc. The new function I'm using requires the unistd.h header file.

http://www.manpagez.com/man/3/usleep/
You could either use a portable version of that function (std::this_thread::sleep_for() for C++11 compilers, boost::this_thread::sleep() for C++98 compilers), or use #ifdef/#endif to select the correct OS-specific function for each platform you're supporting.
I'm using Visual Studio C++ 2010 express, is that C++11? Also, would you give me an example on how to use the portable version.
2010 Express supports a lot of C++11, but not this part. VC11 preview documentation said it supported that part as well, but I haven't tried it.

For 2010 Express, I download boost from www.boostpro.com and use it just like that: boost::this_thread::sleep(boost::posix_time::seconds(1)); for example.
$ whereis unistd.h
unistd: /usr/include/unistd.h
Sorry.
So, after downloading boost from there, I just take my line of code in my source, and replace it with that? For ex:

Sleep(1000);
would become

boost::this_thread::sleep(boost::posix_time::seconds(1));
bump
I still don't understand.
Topic archived. No new replies allowed.