I am working in a dev environment where we produce both 32 and 64 bit executables. I have one application that is failing to build in 64 bit mode. It uses inotify and includes glib.h to get the definitions for that.
I decided to see if a minimal program can cause the problem to happen and here it is.
The source for the test, glibtest.c:
#include <stdio.h>
#include <glib.h>
int
main (int argc, char ** argv)
{
printf( "hello, I am glib test.\n\n");
}
Building in 32 bit mode...
[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] :
Things compile in 32 bit mode and a.out prints what one expects. Now if one compiles in 64 bit mode the error occurs.
[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] :
In 64 bit mode the error points into gthread.h here...
#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__ */
Am I missing a needed header? Has anyone seen this before and found the solution? (yes, there is a similar post from a year ago that no one has answered.)
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 package is 1:1.2.10-33.el6
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Thanks.
/usr/lib/glib-2.0/include
is, generally, platform-specific. It probably contains 32 bit-specific definitions. e.g., I have the following in /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:
#define GLIB_SIZEOF_SIZE_T 8
That would probably be 4 in your version, since it seems to be the 32-bit one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With