Re: Defining Callback without arguments



Shiraz Baig wrote:

I have defined a callback function for "clicking" of a
button. I have not used the normal form of
  callback(GtkWidget *widget, gpointer data).

Instead, I have used a callback without any arugments.
(See the example given below).

My question is
"Is there anything wrong in doing so, when I do not
need to dereference the widget or the data?"

My program is working perfectly fine. I just want to
find out, if there could be some potentional problems
with my program.

My code is as under:

void anyfunc()
{
 g_print("Reached here.\n");
}

main()
{
.............
 button = gtk_button_new_with_label("SEND");
 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE,
TRUE, 10);
 gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(anyfunc),
NULL);
.........
}

All is OK, because you're trying this in "C" language. The "C" will normalize the stack *after* the call, so you did nothing wrong. Other languages (for example "Pascal") doing the stack normalization inside the function - in this case you'll get a bug.

God bless "C" ;)

Olexiy





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