glib.h负数组大小错误(64位而不是32位)

 閆小恰 发布于 2023-01-06 16:15

我在开发环境中工作,我们同时生成32位和64位可执行文件。我有一个无法在64位模式下构建的应用程序。它使用inotify并包含glib.h来获取其定义。

我决定看看最小的程序是否可以导致问题发生,就在这里。

测试的源glibtest.c:

    #include 
    #include 

    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)

谢谢。

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有