Subject: Re: bug#11781: compilation failure: `ULLONG_MAX' undeclared

From: Dan Nicolaescu <[email-masked]>
Date: Tue, 26 Jun 2012 09:10:21 -0400

Dan Nicolaescu <[email-masked]> writes:

> On an ancient machine (don't ask) building the trunk fails:
>
> gcc -c  -Demacs -DHAVE_CONFIG_H  -I. -I/tmp/emacs/src -I../lib -I/tmp/emacs/src/../lib   -I/usr/X11R6/include            -MMD -MF deps/sysdep.d -MP     -g -O2 /tmp/emacs/src/sysdep.c
> /tmp/emacs/src/sysdep.c: In function `time_from_jiffies':
> /tmp/emacs/src/sysdep.c:2587: `ULLONG_MAX' undeclared (first use in this function)
> /tmp/emacs/src/sysdep.c:2587: (Each undeclared identifier is reported only once
> /tmp/emacs/src/sysdep.c:2587: for each function it appears in.)
> make[1]: *** [sysdep.o] Error 1
>
>
> $ cat /etc/redhat-release 
> Red Hat Linux release 7.3 (Valhalla)
>
> $ rpm -q glibc-devel
> glibc-devel-2.2.5-44
>
> $ gcc -v
> Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
> gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113)

The compilation succeeds when using "gcc -std=c99" or "gcc -std=gnu99"

Looking at config.log, it tries to use -std=gnu99 but the test fails:

configure:6807: gcc -std=gnu99 -c -g -O2  conftest.c >&5
conftest.c:68: array size missing in `data'
conftest.c: In function `test_restrict':
conftest.c:85: parse error before `unsigned'
conftest.c:85: `i' undeclared (first use in this function)
conftest.c:85: (Each undeclared identifier is reported only once
conftest.c:85: for each function it appears in.)
conftest.c:85: parse error before `)'
conftest.c: In function `test_varargs':
conftest.c:96: parse error before `args_copy'
conftest.c:97: `args_copy' undeclared (first use in this function)
conftest.c:99: parse error before `const'
conftest.c:108: `str' undeclared (first use in this function)
conftest.c:111: `number' undeclared (first use in this function)
conftest.c:114: `fnumber' undeclared (first use in this function)
conftest.c: In function `main':
conftest.c:134: parse error before `char'
conftest.c:141: parse error before `struct'
conftest.c:143: `ia' undeclared (first use in this function)
conftest.c:144: parse error before `int'
conftest.c:144: `i' undeclared (first use in this function)
conftest.c:144: parse error before `)'
conftest.c:154: `ni' undeclared (first use in this function)
conftest.c:156: parse error before `int'
conftest.c:157: `dynamic_array' undeclared (first use in this function)
conftest.c:160: `newvar' undeclared (first use in this function)
configure:6807: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "emacs"
| #define PACKAGE_TARNAME "emacs"
| #define PACKAGE_VERSION "24.1.50"
| #define PACKAGE_STRING "emacs 24.1.50"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "emacs"
| #define VERSION "24.1.50"
| #define MAIL_USE_POP 1
| #define SYNC_INPUT 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define __EXTENSIONS__ 1
| #define _ALL_SOURCE 1
| #define _DARWIN_C_SOURCE 1
| #define _GNU_SOURCE 1
| #define _POSIX_PTHREAD_SEMANTICS 1
| #define _TANDEM_SOURCE 1
| #define _FILE_OFFSET_BITS 64
| /* end confdefs.h.  */
| #include <stdarg.h>
| #include <stdbool.h>
| #include <stdlib.h>
| #include <wchar.h>
| #include <stdio.h>
| 
| // Check varargs macros.  These examples are taken from C99 6.10.3.5.
| #define debug(...) fprintf (stderr, __VA_ARGS__)
| #define showlist(...) puts (#__VA_ARGS__)
| #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
| static void
| test_varargs_macros (void)
| {
|   int x = 1234;
|   int y = 5678;
|   debug ("Flag");
|   debug ("X = %d\n", x);
|   showlist (The first, second, and third items.);
|   report (x>y, "x is %d but y is %d", x, y);
| }
| 
| // Check long long types.
| #define BIG64 18446744073709551615ull
| #define BIG32 4294967295ul
| #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
| #if !BIG_OK
|   your preprocessor is broken;
| #endif
| #if BIG_OK
| #else
|   your preprocessor is broken;
| #endif
| static long long int bignum = -9223372036854775807LL;
| static unsigned long long int ubignum = BIG64;
| 
| struct incomplete_array
| {
|   int datasize;
|   double data[];
| };
| 
| struct named_init {
|   int number;
|   const wchar_t *name;
|   double average;
| };
| 
| typedef const char *ccp;
| 
| static inline int
| test_restrict (ccp restrict text)
| {
|   // See if C++-style comments work.
|   // Iterate through items via the restricted pointer.
|   // Also check for declarations in for loops.
|   for (unsigned int i = 0; *(text+i) != '\0'; ++i)
|     continue;
|   return 0;
| }
| 
[snip]

Any idea what is going on here?