Re: passing arg 2 of `g_timeout_add' from incompatible pointer type



Yiannis wrote:
OK, I always get the following warning and I never understood why.
passing arg 2 of `g_timeout_add' from incompatible pointer type

A typical example of my code would be:

gboolean
foo(void)
{
return TRUE;
}

g_timeout_add(500, foo, NULL);

Any clues?
Thanks!

It should be "gboolean foo (gpointer user_data)", the GFunc will
be called with the third arg of g_timeout_add() as user_data.

You can also safely ignore the user_data as you did - just cast
foo like this:
    g_timeout_add(500, (GFunc)foo, NULL);

Cheers,
                    -Tristan



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