Re: 64-bit Architecture Pointer Storage




Kevin Cozens <kcozens@interlog.com> writes:

> At 11:45 AM 16/11/1998 -0600, you wrote:
> >Is there any reason pointers are being stored as unsigned
> >ints internally?  Why not use the '*'?
> 
> As far as I'm concernced its a case of sloppy or naive programming. I have
> seen this many times when I used to port various Unix utilities to a DOS
> environment. This should be fixed as it will certainly affect portability
> of the code.

Or, rather, it's a case of people jumping hastily to unwarrented
conclusions ;-)

Apparently the guint's being referred to are:

struct _GtkItemFactoryEntry
{
[...]
  GtkItemFactoryCallback callback;
  guint			 callback_action;
[...]
};

'callback_action' isn't meant to be a pointer. Rather, it's
meant to be a guint.

I think the idea of having it here is to allow several
menu entries to use the same callback. For instance,
if you had radio menu items for justification, you
could have an enumeration with values JUSTIFY_LEFT,
JUSTIFY_CENTER, and JUSTIFY right.

As far as I know, GTK+ never makes the assumption
that it can store a pointer in an uint (and since
many people use GTK+ quite happily on Alpha's, I'm
pretty confident in that statement.) 

It does make the assumption that it is possible to
store small integers in pointers. This is encapsulated
in the:

 G[U]INT_TO_POINTER() and 
 GPOINTER_TO_[U]INT()

macros.

Regards,
                                        Owen





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