llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

limits.h "#include_next madness" misses include system limits.h

Open llvmbot opened this issue 16 years ago • 7 comments

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:

  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 ->
  2. gcc limits.h (which does nothing), include_next ->
  3. system limits.h

My system is Ubuntu Hardy.

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

llvmbot avatar Feb 22 '10 12:02 llvmbot

I think this is fixed. Let me know if not.

echristo avatar Aug 25 '10 10:08 echristo

Nick: Did we ever fix the linux side of things not to require this?

echristo avatar Jul 28 '10 01:07 echristo

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.

echristo avatar Mar 27 '10 11:03 echristo

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.

llvmbot avatar Mar 27 '10 07:03 llvmbot

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

llvmbot avatar Feb 22 '10 12:02 llvmbot

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.

llvmbot avatar Feb 22 '10 12:02 llvmbot

assigned to @echristo

llvmbot avatar Feb 22 '10 12:02 llvmbot