[cfe-dev] include_next missing in several Clang system headers for MinGW

Ruben Van Boxem vanboxem.ruben at gmail.com
Sat Jun 18 14:10:52 PDT 2011


Hi,

MinGW needs more information from the platform's float.h, stddef.h,
stdint.h, and stdarg.h. I have checked with a mingw-w64 developer (Kai
Tietz) and the GCC MinGW headers.

For GCC, float.h, stddef.h, stdarg.h and stdint.h all include_next the
platform header of the same name. I believe this is already OK for
Clang's stdint.h header, which include_next's itself already.

There needs to be a block similar to this one in Clang's stdint.h:
#if __STDC_HOSTED__ && \
    defined(__has_include_next) && __has_include_next(<stdint.h>)
# include_next <stdint.h>
#else

for float.h, stddef.h, stdarg.h if __MINGW32__ is defined. This macro
is defined by Clang on all MinGW platforms (I checked by doing "touch
foo.h" followed by "clang -dM -E foo.h").

MinGW/GCC had the same problem, and was solved by include_next in the
system (GCC) headers. GCC adds these at configure time (or at
fixincludes time, nevertheless, they're not visible in the source
tree). A small compiler specific change will be needed in the
mingw-w64 header float.h to facilitate this, but it will need a
__clang_major__ number to check against. I'm of course hoping for that
to be __clang_major__>= 3...

I have checked that adding an #include_next <float.h> and making the
changes in mingw-w64's float.h gets it right. For the record (and
Kai), the code at the beginning of mingw-w64's float.h should look
like this:
#if (defined (__GNUC__) && defined (__GNUC_MINOR__)) ||
(defined(__clang__) && defined(__clang_major__))
#if (__GNUC__ < 4  || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)) ||
(__clang_major__ >=3)
#if !defined(_FLOAT_H___) && !defined(__FLOAT_H)
#include_next <float.h>
#endif

Thanks!

Ruben

PS: this, along with my other patch for sysrooted header search for
MinGW, allows Qt's qmake to compile with Clang (with a manual
modification to its makefile to use clang++ instead of g++ as compiler
and linker). That's also how I checked the effectiveness of the
proposed change.



More information about the cfe-dev mailing list