Re: GValue won't init inside hidden functions



On 6/28/06, Philip Kovacs <kovacsp3 comcast net> wrote:
I have noticed that issuing a g_value_init() on a GValue produces the error:

GLib-GObject-WARNING **: gvalue.c:89: cannot initialize GValue with type
`gpointer', the value has already been initialized as `(null)'

whenever the function does not have external visibility, i.e. is defined
either as 'static'
or with the attribute G_GNUC_INTERNAL.

Did you remember to initialise the GValue to {0}? The following
program runs with no warnings for me.

/* Compile with:

  gcc -Wall try3.c `pkg-config gobject-2.0 --cflags --libs`

*/

#include <glib-object.h>

static GValue value = { 0 };
static GValue value2 = { 0 };

static void
fred( void )
{
       GValue value3 = { 0 };

       g_value_init( &value2, G_TYPE_POINTER );
       g_value_init( &value3, G_TYPE_POINTER );
}

int
main()
{
       g_type_init();

       g_value_init( &value, G_TYPE_POINTER );

       fred();

       return( 0 );
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]