【发布时间】:2014-07-02 21:17:01
【问题描述】:
我在一个开发环境中工作,我们同时生产 32 位和 64 位 可执行文件。我有一个无法以 64 位模式构建的应用程序。 它使用 inotify 并包含 glib.h 来获取它的定义。
我决定看看一个最小的程序是否会导致问题发生,就在这里。
测试源glibtest.c:
#include <stdio.h>
#include <glib.h>
int
main (int argc, char ** argv)
{
printf( "hello, I am glib test.\n\n");
}
在 32 位模式下构建...
[svn/glibtest] : gcc glibtest.c -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -m32
[svn/glibtest] : a.out
hello, I am glib test.
[svn/glibtest] :
事物以 32 位模式编译,a.out 打印出预期的内容。 现在如果在 64 位模式下编译就会出现错误。
[svn/glibtest] : gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include glibtest.c
In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:34,
from /usr/include/glib-2.0/glib.h:34,
from glibtest.c:7:
/usr/include/glib-2.0/glib/gthread.h: In function ‘g_once_init_enter’:
/usr/include/glib-2.0/glib/gthread.h:347: error: size of array ‘type name’ is negative
[svn/glibtest] :
在 64 位模式下,错误指向 gthread.h 这里...
#if defined (G_CAN_INLINE) || defined (__G_THREAD_C__)
G_INLINE_FUNC gboolean
g_once_init_enter (volatile gsize *value_location)
{
error>>> if G_LIKELY ((gpointer) g_atomic_pointer_get (value_location) != NULL)
return FALSE;
else
return g_once_init_enter_impl (value_location);
}
#endif /* G_CAN_INLINE || __G_THREAD_C__ */
我是否缺少所需的标题?有没有人见过这个并找到解决方案? (是的,一年前有一个类似的帖子没有人回答。)
Centos 6.5,'Linux tushar 2.6.32-431.17.1.el6.x86_64 #1 SMP Wed May 7 23:32:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux'
glib 包是 1:1.2.10-33.el6
gcc (GCC) 4.4.7 20120313 (红帽 4.4.7-4)
谢谢。
【问题讨论】:
-
你看过预处理的源码吗?即
-Egcc 选项 -
你好像用的是旧版本,你能安装更新版本的
glib吗?