2

It always produce an error that cant find "unistd.h" why? Any remedies for this?

3 Answers 3

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

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

2
  • 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! :) Jan 27, 2011 at 9: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, 2011 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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.