Re: [gtk-list] Re: How to use a gpointer?
- From: Alexander Kotelnikov <sacha AK2614 spb edu>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: How to use a gpointer?
- Date: Thu, 4 Mar 1999 13:50:15 +0300 (MSK)
On Thu, 4 Mar 1999, Lars Hallberg wrote:
> On Wed, Mar 03, 1999 at 06:50:19PM -0800, Theodore Roth wrote:
> > This looks kinda dangerous to me:
> >
> > Lars Hallberg wrote:
> > > > GTK_SIGNAL_FUNC(handle_value),(gpointer)???);
> > > GTK_SIGNAL_FUNC(handle_value),(gpointer) value);
> > > >
> > > > the_value=??????data;
> > > the_value= (int) data;
> >
> > Correct me if I'm wrong, but doesn't this make the assumption that
> > sizeof(int)==sizeof(void *)? And wouldn't this cause problems on systems
> > which the assumption is false, e.g. 64 bit systems? I feel the safer way
> > to do it is to pass the reference, as in (gpointer)&value.
>
> You probably right (i got 0 64 bit experiens). Hovewer i think glib
> promis some things to work (probably shuld use gint32 insted of int -
> but that migt be problem on some 16 bit mashines ;-)
>
> This in the start of main will make the problem menefest whenever there:
>
> if(sizeof(int)>sizeof(gpointer))
> exit();
I had not use C on various platforms but:
* sizeof(int) is far from sizeof(gpointer), generaly they can be untied,
'cos if machine have a byte as memory unit it'll be number of bytes per
int, and this is set 'by software' -- with compiler. sizeof(void*) is
number wich depends on architecture. More if you have there are crazy
systems (e.g. DOS) were sizeof(int a)!=sizeof(int b) if a,b are stored in
different memory parts. So your condition will just break program on some
OSes. Anyway, if somebody wanna use it, it should be put to configure
script.
* casting scalar type (int) to pointer (gpointer) is not good idea anyway.
_____
Alexander Kotelnikov
Saint-Petersburg, Russia
mailto:sacha@ak2614.spb.edu
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]