MingW does use InitHeaderSearch to populate the include directories. Frankly, between the C, C++ headers and the hardcoded version directories it’s a big mess.
Regrading the MingW version, practically I found three popular distributions.
- http://www.mingw.org/
- http://tdm-gcc.tdragon.net/
- http://sourceforge.net/projects/mingwbuilds/
The first two are quite easy to support since they are installed to a fixed default directory. Code for the C includes would be:
AddPath(“c:/mingw/include”, System, false);
and
AddPath(“c:/TDM-GCC-32/include”, System, false);
respectively. Library code would be similar.
mingw-builds is smarter installing into different directories based on gcc version, thread package and EH method. So that you can have multiple versions of mingw-builds installed and choose between them by changing the PATH only. I wrote some not-very-elegant code (below) for the C includes of mingw-builds, I think it’s not committed to svn.
For C++ headers, a decision to be made is if the clang+MingW uses by default libstdc++ or libcxx headers and if libcxx, where it is to be found. This may be changed later by the user with -nostdinc and such but it is an headache of flags. Maybe a command line flag?
Yaron
// mingw-builds include path.
// Recursively search all dirs for i686-w64-mingw32, include below.
llvm::error_code EC;
for (llvm::sys::fs::recursive_directory_iterator
Dir(“c:\Program Files (x86)\mingw-builds”, EC),
DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
std::string DirName = Dir->path();
if (llvm::sys::fs::is_directory(DirName)) {
if (DirName.find(“i686-w64-mingw32”) != std::string::npos) {
SmallString<512> P = DirName;
llvm::sys::path::append(P, “include”);
AddPath(P.str(), System, false);
// Stop searching upon first find.
break;
}
}
}