8

I'm compiling grep on the 64-bit GCC compiler for Windows 7 x64 SUA/Interix.

It chokes on the marked line in stddef.h:

#ifndef _SIZE_T_DEFINED
#if defined (lp64) || defined(_WIN64)
#ifdef lp64
typedef unsigned long   size_t;                    //    <------ error
#else /* lp64 */
typedef unsigned __int64        size_t;
#endif /* lp64 */
#else /* (defined(lp64) || defined(_WIN64)) */
typedef unsigned int  size_t;
#endif /* (defined(lp64) || defined(_WIN64)) */
#define _SIZE_T_DEFINED
#define _SIZE_T
#endif /* _SIZE_T_DEFINED */

The output for make is:

make  all-recursive
Making all in intl
gcc -c -DLOCALEDIR=\"/usr/local/share/locale\" -DLOCALE_ALIAS_PATH=\"/usr/local/share/locale\"  -DLIBDIR=\"/usr/local/lib\" -DIN_LIBINTL -DHAVE_CONFIG_H -I.. -I. -I../../intl -D_ALL_SOURCE -D_REENTRANT -I/usr/local/include -I/usr/local/include -D_ALL_SOURCE -D_REENTRANT  ../../intl/intl-compat.c

In file included from ../../intl/gettextP.h:23:0,
                 from ../../intl/intl-compat.c:25:
/usr/include/stddef.h:50:23: error: duplicate 'unsigned'
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build/intl.
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build (line 329 of Makefile).
*** Error code 1

Stop in /tmp/grep-2.5.4-src/build (line 244 of Makefile).

I don't understand what the cause is... it's already confusing that long is being used as though it's 64-bit in GCC, but the error is even more confusing! Ideas?

user541686
  • 205,094
  • 128
  • 528
  • 886
  • 1
    Looks like long has been #defined to unsigned somewhere earlier in the include chain. – Joachim Isaksson Jan 11 '12 at 21:51
  • Is it possible that `size_t` is pre-defined as a macro, say `#define size_t unsigned int` or something, but that `_SIZE_T_DEFINED` is not defined? Then the problematic line would be equivalent to `typedef unsigned long unsigned int;` (or the like), which would trigger that error-message. – ruakh Jan 11 '12 at 21:51
  • You guys are absolutely right :) thanks for the pointer, it was pretty baffling. – user541686 Jan 11 '12 at 21:53

1 Answers1

12

Somewhere in your code, somone probably did:

#define size_t unsigned long

Or something along those lines, without having defined _SIZE_T_DEFINED when they did it. Then their code #includes stddef.h via the path listed in your error message. That makes your error line look like:

typedef unsigned long unsigned long;

To the compiler, which is not going to work!

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
  • 1
    :O indeed, I just searched with `grep` (how meta...) and saw: `./config.h:#define size_t unsigned int`... thanks! – user541686 Jan 11 '12 at 21:53
  • The autoconf must have assumed a very outdated compiler/implementation for it to define `size_t` as a macro... – dreamlax Jan 11 '12 at 21:55
  • @dreamlax: Yeah, I feel like I didn't configure it right -- I was having [trouble](http://stackoverflow.com/questions/8825472/c-compiler-cannot-create-executables-on-sua-interix) with getting `configure` to work. :) – user541686 Jan 11 '12 at 21:58