glib.h在64位但不是32位构建的负数组大小错误

问题描述:

我在开发环境中工作,我们同时生产32位和64位 可执行文件。我有一个应用程序无法在64位模式下构建。 它使用inotify并包含glib.h以获取该定义。glib.h在64位但不是32位构建的负数组大小错误

我决定看看一个最小的程序是否会导致问题的发生。

源进行测试,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的 油嘴包是1:1.2.10-33.el6
GCC(GCC)4.4.7 20120313(红帽4.4.7-4)

感谢。

+3

你看过预处理源吗? I.e'-E' gcc选项 –

+0

您似乎正在使用旧版本,您可以安装更新版本的'glib'吗? – ouah

/usr/lib/glib-2.0/include通常是平台特定的。它可能包含32位特定的定义。例如,我有在/usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h如下:

#define GLIB_SIZEOF_SIZE_T 8 

这很可能是4您的版本,因为它似乎是32位之一。