Use dirent.h in MSVC 2008

I have a problem to add dirent.h in the project. These days I start to use dirent.h windows API(http://www.softagalleria.net/dirent.php) to read the specific files in the directory in Visual C++ 2008 professional. I wrote a test codes, everything is fine. But if I used in my project(use dirent.h in one of the class), it doesn't work anymore.

If I put #include "dirent.h" in class .cpp file, error messgae shows
 
fatal error C1083: Cannot open include file: 'dirent.h': No such file or directory

If I put it in class header file, 100 error messages came out. Here is the example.
1
2
3
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\specstrings.h(171) : error C2008: '$' : unexpected in macro definition
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\specstrings.h(172) : error C2008: '$' : unexpected in macro definition
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\specstrings.h(172) : warning C4005: '__' : macro redefinition


I already put dirent.h in VC\include\ directory. Any ideas? Thanks
Last edited on
dirent.h is a POSIX specific header file, not a standard C/C++ header file, so it should only be available on POSIX platforms.
http://opengroup.org/onlinepubs/007908799/xsh/dirent.h.html
That's why I use this windows API version
http://www.softagalleria.net/dirent.php

It works in my test codes, but not in the project involving many classes
I see what you mean. It's straight forward to knock up a POSIX style dirent based lib for Windows that doesn't add much overhead, clearly softagalleria.net have tried it, and cygwin do a good job of it too.

The fact is, it's a UNIX specific API. There is a Windows specific equivalent that uses: FindFirstFile()/FindNextFile()/FindClose().
Cause this project is contributed by many people, and we all use Visual C++ 2008. That's why I stick to softagalleria's dirent.h. Otherwise other people still can't compile and use the codes.
Does anybody have the same experience?
Topic archived. No new replies allowed.