Nat*_*man 4 gtk gcc cross-compiling
我正在为Windows交叉编译GTK + 3.4.4.我已经交叉编译了GTK(ATK,Cairo,GDK Pixbuf和Pango)的所有构建依赖项并将它们安装到了/usr/i686-w64-mingw32/.
但是,尝试编译GTK本身会导致以下错误:
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
Run Code Online (Sandbox Code Playgroud)
第34-44行gdk/fallback-c89.c包含:
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
Run Code Online (Sandbox Code Playgroud)
我对GCC找到' sizeof'或' ==的地方一无所知.为什么编译器抛出这样一个神秘的错误信息,我该如何修复它?
编辑:这是实际的命令行:
/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
Run Code Online (Sandbox Code Playgroud)
进一步编辑:在使用该-E选项进行编译后,我捕获了以下预处理输出...这解释了奇怪的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));
}
Run Code Online (Sandbox Code Playgroud)
我只能得出结论,isinf它已经是一个定义的宏.在上面的函数声明中使用时,它只是被扩展.
我的问题现在变成......为什么HAVE_ISINF没有定义?这是配置脚本的问题吗?
还有另一个编辑:好的,所以我决定在构建树中搜索包含字符串' HAVE_ISINF'的所有内容,并遇到以下实例:
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])
Run Code Online (Sandbox Code Playgroud)config.h.in
/* Define to 1 if you have the `isinf' function. */
#undef HAVE_ISINF
Run Code Online (Sandbox Code Playgroud)config.h中
/* Define to 1 if you have the `isinf' function. */
/* #undef HAVE_ISINF */
Run Code Online (Sandbox Code Playgroud)令人惊讶的是,没有config.log提到"HAVE_ISINF".
(可能)最终编辑:我做了一些调查,发现字符串'isinf'在autom4te.cache/output.0这里:http://paste.ubuntu.com/1154478/
这段代码引用了ac_fn_c_check_func,所以我挖出了该函数的源代码并编译了脚本生成的.c示例:
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
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为我上面的解释表明这isinf只是一个宏.