Subject: Gnome-core/limits.h problem

From: Russell King <[email-masked]>
Date: Sun, 17 Jan 1999 14:52:26 +0000 (GMT)

Hi,

I've just encountered a problem with gnome-core and limits.h:

While building gnome-core/panel/session.c, GCC complains that INT_MAX is not
defined.  Looking at the problem, it appears that GCC's action of #include_next
is wrong.

If you call GCC with:

	gcc -I/usr/include -I. -I/usr/include ... -c file.c

your <...> search path contains:

	/usr/include
	.
	/usr/include
	/usr/local/include
	/usr/arm-linuxelf/include
	/usr/lib/gcc-lib/arm-linuxelf/2.8.1/include
	/usr/include

And file.c #include's <limits.h>, then you end up with the following problem:

/usr/include/limits.h is included, which defines
	_LIBC_LIMITS_H_
to protect against multiple inclusions.

/usr/include/limits.h includes various other header files from /usr/include/bits,
and then #include_next's <limits.h>

Since the current file was included from the first /usr/include entry in the
search path, it then tries ./limits.h (which does not exist), and then
/usr/include/limtis.h, which does exist.  It starts pre-processing this file
and encounters #ifndef _LIBC_LIMITS_H_, which prevents any of limits.h being
included.

This means that the intended /usr/lib/gcc-lib/arm-linuxelf/2.8.1/include/limits.h
which contains the definition of INT_MAX for the architecture never gets included.

Surely GCC ought to either prevent duplications of header file paths, or remember
which ones have already been included and not re-include them on #include_next,
but carry on searching for another header file?

Anyway, the fix I applied was to simply comment out the #ifndef _LIBC_LIMITS_H_
since all the other header files are protected in a similar manner anyway,
and we're using GCC >2.0.0.

This is not the first time I've encountered this problem with various versions
of GCC, and have in the past fixed the flags passed to GCC.  However, with the
way the gnome autoconf stuff works, it'll be very messy to fix it in every case
without breaking someone's environment.  IMHO, it's a gcc problem, since GCC's
just being plain daft.
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [email-masked]      --- ---
  | | | |   http://www.arm.linux.org.uk/~rmk/aboutme.html    /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Philip Blundell <[email-masked]>
Date: Sun, 17 Jan 1999 19:16:25 +0100

Russell King wrote:

>way the gnome autoconf stuff works, it'll be very messy to fix it in
>every case without breaking someone's environment.  IMHO, it's a gcc 
>problem, since GCC's just being plain daft.

The compiler is just doing what you tell it.  If you say
`-I/usr/include' twice, it will search that directory twice.  It's not
GCC's job to second guess the user.

The problem should go away if you install a newer glibc.  If not then
let me know and I'll look into it.

p.

---

From: Russell King - ARM Linux Admin <[email-masked]>
Date: Mon, 18 Jan 1999 22:04:07 +0000 (GMT)

> GCC's job to second guess the user.

Correction - it's doing what dumb autoconf is telling it to do; I played
no part in the options it chose.
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |        Russell King       [email-masked]      --- ---
  | | | |  http://www.arm.linux.org.uk/~rmk/armlinux.html    /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]