Re: Typecast error



On Tuesday 13 March 2001 06:26, CyborgHead netscape net wrote:
> Hello All.
>   I have a tiny problem, that doesn't really matter, but I would like
> it to be fixed. In my program I have the following command
>
> gtk_signal_connect( GTK_OBJECT( robot_name[1] ), "clicked",
>         GTK_SIGNAL_FUNC( display_info ), 1 );
>
> which calls the following function
>
> void display_info( GtkWidget *was_clicked, int i )
> {
>     cout<<i;
>     etc...
>     etc...
> }
>
> This program compiles and creates an executable which works
> correctly, ie. ithe int is successfully passed to the function,
> however I get this warning, which I would like to fix
>
> gui.h:873: cannot convert `int' to `void *' for argument `4' to
> `gtk_signal_connect (GtkObject *, const gchar *, void (*) (), void
> *)'
>

It wants a pointer to something, so, we give it one:

  gint dummy_int = 1;
  gtk_signal_connect( GTK_OBJECT( robot_name[1] ), "clicked",
          GTK_SIGNAL_FUNC( display_info ), &dummy_int );

  ...

  void display_info( GtkWidget *was_clicked, gint *i )
  {
      cout << *i;
  }

You might need to fuss a bit with a cast but it should be less
painful that what you've been through.

--Dwight Tuinstra
    tuinstra northnet org




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