<dirent.h> in Visual C++

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/XinYaping/article/details/51444133

问题

在 Visual C++ 中某些开源的源代码时,偶尔会遇到一个问题:无法找到 dirent.h 这个文件:

Cannot open include file: ‘dirent.h’: No such file or directory

解决方案

Dirent API for Microsoft Visual Studio 这篇文章中提到了如何获得 dirent.h 这个文件。可以直接从 Github: tronkko/dirent 获得这个文件。

说明

dirent.h 是一个来自于 C POSIX library 的文件,通常被包含在 GCC (Cross-platform)、MinGW (Microsoft Windows)、Borland C++ 这些编译器中,但是 MSVC 并不包含此文件。
幸运的是,dirent.h 有以下一些开源的实现,我们可以将其应用于 MSVC 的程序中:

  1. free Windows implementation of dirent.h (基于 MIT license 开源)
  2. POSIX Directory Browsing API for Windows (作者 Kevlin Henney 已将授权许可说明附在源代码文件中)

参考文章

猜你喜欢

转载自blog.csdn.net/XinYaping/article/details/51444133
今日推荐