Re: glib question - g_thread_create in a c++ program



Dodiesis wrote:

i've got this error:
chat_app.cpp:25: error: argument of type `void*(chat_app::)(void*)' does
not match `void*(*)(void*)'

the fast solution is to keep out "main_loop" from the class and give to
it the ptr of class instance:
        g_thread_create(main_loop, this, TRUE, NULL)

but in this way i cannot use the private methods...

Make your main_loop() a static method of chat_app.

class chat_app ... {

   static gpointer main_loop(chat_app *o);


};


is it possible to make a casting?
No. Read a bit about pointer to class members; comp.lang.c++.moderated is a good start. A pointer to a non-static class member is not a plain pointer; so a pointer to a non-static method can't be stored in a plain C function pointer.



Daniel K. O.




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