我在开发环境中工作,我们同时生成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)
谢谢。