It always produce an error that cant find "unistd.h" why? Any remedies for this?
Asked
Active
Viewed 2,343 times
3 Answers
3
Services for Unix ships with various linux related headers (including unistd.h), so you could use that. But that might require to link some of the SFU libraries..

smerlin
- 6,446
- 3
- 35
- 58
2
Why? It's just not there. It looks like you try to compile a program that is not portable or you try to port the program to Windows.
unistd.h
is a not a standard header. Probably you find it only on Unix-like systems.
See: Wiki

harper
- 13,345
- 8
- 56
- 105
-
If the program uses unistd.h, it should compile fine on Linux, the BSDs, and OSX - I would say that's "portable" (also, I would personally call it a "standard header", but I spend a lot of time around POSIX so you may feel differently). The issue is that it's not portable to Windows, which does not provide unistd.h. #ifdef WIN32 to the rescue! :) – Matthew Iselin Jan 27 '11 at 09:01
-
@Matthew Iselin: I don't want to claim a definitiv definition of "portable". But I could give a list of environments that does not include this header too. If you have a "standard header" you need to tell us the "standard". ANSI C might be one, POSIX another. So you can find something more or less "portable". At least the (POSIX) code in question is not portable to "visul-c++" for which this question is tagged. – harper Jan 27 '11 at 12:42
0
See Is there a replacement for unistd.h for Windows (Visual C)? for a partial replacement. (If you can add aditional functionality, please do so).