C++ <dirent.h> 在 Visual Studio 2010 或 2008 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5530933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
<dirent.h> in visual studio 2010 or 2008
提问by amiref
I want to use #include<dirent.h>
in my code but this error happen:
我想#include<dirent.h>
在我的代码中使用,但发生此错误:
Cannot open include file: 'dirent.h': No such file or directory
无法打开包含文件:'dirent.h':没有这样的文件或目录
How can I solve this problem ?
我怎么解决这个问题 ?
回答by Nawaz
Because this header file doesn't come with MSVC. Hence it cannot find it!
因为这个头文件不是 MSVC 自带的。因此它找不到它!
It comes with C POSIX library. The wikipediasays,
它带有C POSIX 库。在维基百科说,
dirent.h is known to be included in the following compilers:
- Turbo C++ (DOS)
- GCC (Cross-platform)
- MinGW (Microsoft Windows)
- Borland C++ Builder (Microsoft Windows)
Microsoft Visual C++ does not include dirent.h
已知 dirent.h 包含在以下编译器中:
- 涡轮 C++ (DOS)
- GCC(跨平台)
- MinGW (微软视窗)
- Borland C++ Builder (Microsoft Windows)
Microsoft Visual C++ 不包含 dirent.h
However, you can download free Windows implementation of dirent.hwhich you can use with Microsoft Visual Studio.
但是,您可以下载可与 Microsoft Visual Studio 一起使用的 dirent.h 的免费 Windows 实现。
回答by Domi
This is another light-weight dirent.h implementation for Windows. It is two files that you can just drop in as-is.
这是 Windows 的另一个轻量级 dirent.h 实现。这是两个文件,您可以按原样放入。
Currently, the best way of getting full POSIX supporton Windows is probably Cygwin or its friends.
目前,在 Windows上获得完整 POSIX 支持的最佳方法可能是Cygwin 或其朋友。
There is Windows Services for UNIX(SfU), but according to someit was quite close to what Cygwin was in 2006. Seeing how Cygwin and some of its comrads are live and well and SfU did not see an update in over half a decade, I would choose the former any day of the week.
有适用于 UNIX 的 Windows 服务(SfU),但根据一些人的说法,它与 2006 年的 Cygwin 非常接近。 看到 Cygwin 和它的一些伙伴是如何生活得很好并且 SfU 没有看到超过五年的更新,我会在一周中的任何一天选择前者。
If you are interested in a blast from the past, checkout this little nugget from 2006which is Microsoft's official How to port from UNIX to Windowswebsite. It seems rather useless, but funny what Microsoft thought is "useful" in 2006.
如果您对过去的爆炸感兴趣,请查看2006 年的这个小块,它是 Microsoft 的官方如何从 UNIX 移植到 Windows网站。看起来相当无用,但有趣的是微软在 2006 年认为“有用”的东西。