开发者

Alternative unistd.h header file for Visual Studio 2010

I am compilin开发者_运维问答g the code in Visual Studio 2010 which includes header file unistd.h. Since windows does not have any support for the header file unistd.h , I am looking for the alternative header file or is there any way to customize it so that I can compile it in Visual Studio as well.


Try include io.h, it's equivalent of unistd.h in MSVC. if you want to maintain the compatibility, try this:

#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif


Your best bet, rather than trying to fit an inappropriate header file into Windows, is simply to remove the line:

#include <unistd.h>

then try and compile your code.

You may find (if you're extremely lucky) that it uses no features of that at all.

However, more likely is that there are certain things that it will use from that header and any associated libraries, and you will need to either implement these or find a Windows equivalent.

If you wanted to keep the code as portable as possible, I would create a WindowsUniStd.h file (and an associated source file) to implement the bare minimum needed by the program.


If you need a minimal GNU environment for windows with some of the functionality of unistd.h, you would look to the MinGW project first. If you're lucky, you can get away without using their compiled libraries at all.

If that isn't enough, you are into porting a program, and you are porting onto the bad system. Windows is computational backwater, providing a full unistd.h is a Herculean task, and you're probably better of either rewriting the application to remove references to unistd.h or using Cygwin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜