Re: GLib 64 bit integer problem revisited



Jeff Franks <jcf tpg com au> writes:

> Hi,
> 
> I asked this one before but the problem is still occuring.
> 
> The C++ wrapper classes I've written use functions with the following
> arguments:
> 
> void get(gint& value) const;
> void get(guint& value) const;
> void get(gint64& value) const;
> void get(guint64& value) const;
> 
> void set(gint value);
> void set(guint value);
> void set(gint64 value);
> void set(guint64 value);
> 
> Compilation on a 64 bit machines (ia64 and alpha) produces the
> following error messages:
> 
> g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../.. -Wall -g -O2
> -I/usr/include/atk-1.0 -I/usr/include/glib-2.0
> -I/usr/lib/glib-2.0/include -Wall -g -O2 -MT action.lo -MD -MP -MF
> .deps/action.Tpo -c action.cc  -fPIC -DPIC -o .libs/action.lo
> In file included from ../../inti/glib/property.h:38,
>                   from ../glib/object.h:40,
>                   from action.cc:23:
> ../../inti/glib/value.h:157: `Inti::G::Value::get (gint64 &) const' has
> already been declared in `Inti::G::Value'
> ../../inti/glib/value.h:161: `Inti::G::Value::get (guint64 &) const'
> has already been declared in `Inti::G::Value'
> ../../inti/glib/value.h:245: `Inti::G::Value::set (long int)' has
> already been declared in `Inti::G::Value'
> ../../inti/glib/value.h:249: `Inti::G::Value::set (long unsigned int)'
> has already been declared in `Inti::G::Value'
> make[4]: *** [action.lo] Error 1
> 
> This is from someone else. I don't have a 64 bit machine so can't test
> this myself but from the error message it looks like on these machines
> the typedefs for gint and  gint64, and guint and guint64 are the same,
> that is "signed long int" and "unsigned long int" respectivley.
> 
> Owen previously said he didn't know of any machines using 64 bit integers.
> 
> Do these machines use 64 bit integers? Is there a problem with the
> GLib typedefs on these machines. I'm a bit lost and any advice would
> be appreciated.

Thse machines have 64-bit longs, not 64-bit ints.

The problem you are running into is that gint64 and 'long int' ae
the same.

I'm not really sure that there is much you can do here .. you'll
probably just have to punt the issue and go with:

 Inti::G::Value::get64 (gint64 &)
 Inti::G::Value::set64 (gint64)

The problem is that the C++ equivalent of:

 g_value_set_int64 (value, num);

Needs to leave the value with a type of G_TYPE_INT64, so it has
to be distinct from the C++ equivalent of g_value_set_long (value, num);

In hindsight, having both int/long and int64 for GValue is probably 
a bad idea; it probably would have been better to just have int32 
and int64... but not something we can change at this point.

Regards,
                                        Owen



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