limits.h "#include_next madness" misses include system limits.h
| Bugzilla Link | 6379 |
| Resolution | FIXED |
| Resolved on | Aug 25, 2010 03:53 |
| Version | trunk |
| OS | Linux |
| Attachments | patch that implements the above |
| Reporter | LLVM Bugzilla Contributor |
| CC | @DougGregor,@echristo,@sunfishcode |
Extended Description
lib/Headers/limits.h includes the following:
/* The system's limits.h may, in turn, try to #include_next GCC's limits.h. Avert this #include_next madness. */ #if defined GNUC && !defined GCC_LIMITS_H #define GCC_LIMITS_H #endif
And then does an #include_next <limits.h> at the end.
I believe that it's intended that the #include_next chain works like this:
- clang limits.h, include_next ->
- system limits.h, include_next ->
- gcc limits.h (which does nothing due to the above #define)
However, on my system, the include path ordering (as according to gcc -v) makes it so instead I get the following:
- clang limits.h, include_next ->
- gcc limits.h, which does nothing
At the end of the gcc limits.h, in a !defined(GCC_LIMITS_H) branch, it has the following:
#ifdef _GCC_NEXT_LIMITS_H #include_next <limits.h> /* recurse down to the real one */ #endif
So if we define that macro in the LLVM header, we get the correct behavior:
- clang limits.h, include_next ->
- gcc limits.h (which does nothing), include_next ->
- system limits.h
My system is Ubuntu Hardy.
% dpkg -s gcc | grep ^Version Version: 4:4.2.3-1ubuntu6
I think this is fixed. Let me know if not.
Nick: Did we ever fix the linux side of things not to require this?
Yep. That's all done. I've been meaning to grab you and let you know that you can fix the linux includes to remove that.
Eric, you said you were going to look into writing some clang versions of the gcc headers so that we could eventually fix this bug by removing the gcc search path entirely.
BTW, my library search path, from touch empty.cpp; gcc -v empty.cpp -fsyntax-only , is
/usr/include/c++/4.2 /usr/include/c++/4.2/x86_64-linux-gnu /usr/include/c++/4.2/backward /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/4.2.4/include /usr/include
From the blame, it appears "mrs" wrote the original "madness" comment, but I can't figure out how to CC him/her on this bug.
assigned to @echristo