Re: g_object_[add|remove]_weak_pointer needs an explicit cast



Tim Janik <timj gtk org> writes:

> On 19 Aug 2001, Sven Neumann wrote:
> 
> > Hi,
> > 
> > I've added this code myself, but have now found that to use 
> > g_object_[add|remove]_weak_pointer() one has to write code
> > like
> > 
> >  g_object_add_weak_pointer (G_OBJECT (foo->object),
> >                             (gpointer *) &foo->object);
> > 
> > since gcc doesn't seem to like the simpler
> > 
> >  g_object_add_weak_pointer (G_OBJECT (foo->object),
> >                             &foo->object);
> > 
> > I propose we apply the attached simple patch to remove the
> > need to insert an explicit cast. The name weak_pointer_location
> > should be clear enough to outline that we expect a pointer to
> > a pointer location here. Any objections?
> > 
> 
> >  void        g_object_add_weak_pointer         (GObject        *object, 
> > -                                               gpointer       *weak_pointer_location);
> > +                                               gpointer        weak_pointer_location);
> 
> nope, that's fine. the same thing should be done for:
> 
> gboolean              g_module_symbol        (GModule      *module,
>                                               const gchar  *symbol_name,
>                                               gpointer     *symbol);
> 
> as in its current incarnation, it requires casting for
> the symbol location in 95% usage cases.

Making something a 'gpointer' just to avoid casting makes me
uncomfortable...  you've thrown away useful information,
and people have enough trouble understanding & and ** without
hiding things behind 'gpointer'.

I'd rather see it as GObject **.

Regards,
                                        Owen




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