Why is GCC complaining about missing identifiers before a 'sizeof' that doesn't exist?

cross-compiling, gcc, gtk

Solution

I finally found this. In summary:

"The isnan() and isinf() are C99 macros not functions so use AC_CHECK_DECL instead of AC_CHECK_FUNCS for those."

So it looks like I'll be patching the source.

Problem

I'm in the process of cross-compiling GTK+ 3.4.4 for Windows. I have already cross-compiled all of the build dependencies for GTK (ATK, Cairo, GDK Pixbuf, and Pango) and installed them to `/usr/i686-w64-mingw32/`. Attempting to compile GTK itself, however, results in the following error: ``` In file included from gdkrgba.c:31:0: fallback-c89.c:40:1: error: expected identifier or '(' before 'sizeof' fallback-c89.c:40:1: error: expected ')' before '==' token ``` Line 34 - 44 of `gdk/fallback-c89.c` contains: ``` 34. #ifndef HAVE_ISINF 35. /* Unfortunately MSVC does not have finite() 36. * but it does have _finite() which is the same 37. * as finite() except when x is a NaN 38. */ 39. static inline gboolean 40. isinf (double x) 41. { 42. return (!_finite (x) && !_isnan (x)); 43. } 44. #endif ``` I haven't the slightest idea where GCC is finding '`sizeof`' or '`==`'. Why is the compiler throwing such a cryptic error message and how can I fix it? Edit: here is the actual command line: ``` /usr/bin/i686-w64-mingw32-gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -DG_LOG_DOMAIN="Gdk" -DGDK_COMPILATION -I.. -I../gdk -I.. -DG_DISABLE_CAST_CHECKS -mms-bitfields -I/usr/i686-w64-mingw32/include/pango-1.0 -I/usr/i686-w64-mingw32/include/glib-2.0 -I/usr/i686-w64-mingw32/lib/glib-2.0/include -I/usr/i686-w64-mingw32/include/cairo -I/usr/i686-w64-mingw32/include/pixman-1 -I/usr/i686-w64-mingw32/include -I/usr/i686-w64-mingw32/include/freetype2 -I/usr/i686-w64-mingw32/include/libpng15 -I/usr/i686-w64-mingw32/include/gdk-pixbuf-2.0 -O2 -Wall -mms-bitfields -MT gdkrgba.lo -MD -MP -MF .deps/gdkrgba.Tpo -c gdkrgba.c -DDLL_EXPORT -DPIC -o .libs/gdkrgba.o ``` Further edit: after compiling with the `-E` option, I captured the following pre-processed output... which explains the strange `sizeof`: ``` # 39 "fallback-c89.c" static inline gboolean ((sizeof (double x) == sizeof (float) ? __fpclassifyf (double x) : sizeof double x)) == (0x0100 | 0x0400)) { return (!_finite (x) && !_isnan (x)); } ``` I can only conclude that `isinf` is already a defined macro. It is merely being expanded when used in the function declaration above. My question now becomes... why is `HAVE_ISINF` not defined? Is it a problem with the configure script? Yet another edit: okay, so I decided to search for everything in the build tree that contained the string '`HAVE_ISINF`' and came across the following instances: autom4te.cache/traces.1 ``` m4trace:configure.ac:740: -1- AH_OUTPUT([HAVE_ISINF], [/* Define to 1 if you have the `isinf\' function. */ @%:@undef HAVE_ISINF]) ``` config.h.in ``` /* Define to 1 if you have the `isinf' function. */ #undef HAVE_ISINF ``` config.h ``` /* Define to 1 if you have the `isinf' function. */ /* #undef HAVE_ISINF */ ``` Surprisingly, there is nothing in `config.log` mentioning `HAVE_ISINF'. (Possibly) final edit: I did some more investigation and found the string 'isinf' in `autom4te.cache/output.0` here: http://paste.ubuntu.com/1154478/ This code made a reference to `ac_fn_c_check_func`, so I dug up the source for that function and compiled the `.c` sample that the script generates: ``` test.c:25:6: warning: conflicting types for built-in function ‘isinf’ [enabled by default] /tmp/ccLYd1R8.o:test.c:(.text+0xc): undefined reference to `_isinf' collect2: ld returned 1 exit status ``` This is odd since my explanation above would suggest that `isinf` is simply a macro.

Original source