简体   繁体   English

为 Windows 实现自定义 unistd.h 以在 Visual Studio 上工作 - 问题

[英]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.我继承了最初为 linux 编写的 dll 文件的源代码。 I'm using windows and visual studio and a change to linux is a no can-do, unfortunately.不幸的是,我正在使用 Windows 和 Visual Studio,但无法更改为 linux。 In particular, one of the classes requires unistd.h.特别是,其中一个类需要 unistd.h。

Since windows does not have anything like unistd.h, I tried implementing one in accordance with what was nicely written here .由于 windows 没有像 unistd.h 这样的东西,我试着按照这里写得很好的内容来实现一个。

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我创建了一个头文件 unistd.h 并将其添加到我的项目的头文件中(我还根据这个做了一个自定义的 getopts。不幸的是,这并没有解决我的问题 - 我的代码不会构建,当我不断得到

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.我的自定义 unistd.h 是我的解决方案的头文件之一,所以我完全不明白出了什么问题。 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.看起来您的所有头文件和源文件都应该在同一个 VS 项目文件夹中 - 原始头文件和源文件在我的计算机上的另一个文件夹中,在创建新项目后,我使用添加现有项目并找到并选择它们添加。

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.我后来通过向项目添加一个新项目创建了 unistd.h 文件 - 实际上这两个文件组位于两个不同的位置,这导致他们没有“看到”自定义 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.这不是代码或我包含头文件的方式的问题,而是文件的放置问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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