[LLVMbugs] [Bug 6379] New: limits.h "#include_next madness" misses include system limits.h

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 22 02:34:16 PST 2010


http://www.llvm.org/bugs/show_bug.cgi?id=6379

           Summary: limits.h "#include_next madness" misses include system
                    limits.h
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Headers
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: evan at chromium.org
   Estimated Hours: 0.0


Created an attachment (id=4278)
 --> (http://www.llvm.org/bugs/attachment.cgi?id=4278)
patch that implements the above

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:
1) clang limits.h, include_next ->
2) system limits.h, include_next ->
3) 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:
1) clang limits.h, include_next ->
2) *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:

1) clang limits.h, include_next ->
3) gcc limits.h (which does nothing), include_next ->
2) system limits.h


My system is Ubuntu Hardy.

% dpkg -s gcc | grep ^Version
Version: 4:4.2.3-1ubuntu6

-- 
Configure bugmail: http://www.llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the llvm-bugs mailing list