How to use dirent.h with Visual Studio

dirent.h is a header file that is found only on Linux systems. It provides data structures and function calls to open and read the contents of directories. If you are trying to port Linux code that uses this header file to Windows, you will that it is not available with Visual Studio.

Thankfully, there is a Windows implementation of dirent.h which can be downloaded here on Github. Just download the zip file, find the dirent.h header file and place it in your Visual Studio include directory. For example, with Visual Studio Express 2015, this directory is C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include

Tried with: Visual Studio Express 2015 and Windows 7 x64

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s