Glib.h array size error in 64-bit but not 32-bit assembly

I work in a dev environment where we produce both 32 and 64 bit executables. I have one application that cannot build in 64 bit mode. It uses inotify and includes glib.h to get definitions for this.

I decided to see if a minimal program can cause a problem, and here it is.

Source for the glibtest.c test:

    #include <stdio.h>
    #include <glib.h>

    int
    main (int argc, char ** argv)
    {
        printf( "hello, I am glib test.\n\n");
    }

Creation 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 it expects. Now, if one compiles in 64-bit mode, an 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 to 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__ */

Is there a heading missing? Has anyone seen this before and found a solution? (Yes, there is a similar post from a year ago, to which no one 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 1:1.2.10-33.el6
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)

.

+4
1

/usr/lib/glib-2.0/include, , . , , 32- . , /usr/lib/x 86_64-linux-gnu/glib-2.0/include/glibconfig.h:

#define GLIB_SIZEOF_SIZE_T 8

, , 4 , 32-.

0

Source: https://habr.com/ru/post/1546923/


All Articles