简体   繁体   中英

Implementing a custom unistd.h for windows to work on Visual Studio - problems

I've inherited source code for a dll file that was originally written for linux. I'm using windows and visual studio and a change to linux is a no can-do, unfortunately. In particular, one of the classes requires unistd.h.

Since windows does not have anything like unistd.h, I tried implementing one in accordance with what was nicely written here .

I created a header file unistd.h and added it to the header files of my project (I also made a custom getopts, in accordance with this . Unfortunately, this hasn't fixed my problem by much - my code won't build, as I keep getting

Cannot open include file: 'unistd.h': No such file or directory

My custom unistd.h is among the header files of my solution, so I completely don't understand what's wrong. I've included it using

#include "unistd.h"

since it is a custom header.

Any suggestions and help will be appreciated. Thank you for the attention.

It appears that all your header and source files should be in the same VS project folder - the original header and source files where on my computer in another folder and after creating a new project I used add existing item and found and chose them to add.

The unistd.h file I created later by adding a new item to the project - effectively both file groups where in two different places and that contributed to the fact that they didn't "see" the custom unistd.h. It wasn't a problem with the code or the way I included the header file, but with the placing of the files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM