[SDL] SDL_CreateThread with C++ method as a parameter

Guilherme Farrer farrer at gmail.com
Sat Mar 22 06:55:40 PDT 2008


2008/3/22, PS3-690 <daimler3 at googlemail.com>:
> Hello,
>
> I have a problem with SDL_CreateThread. I want to use it with a C++ method:
> SDL_CreateThread(function, NULL);
> But then I get an Error:
> "argument of type `int (Class::)(void*)' does not match `int (*)(void*)"

The problem is that the C++ pointer to a class member function is
different from a pointer to a C function (and SDL_CreateThread expects
a C function). To fix this, create the thread with a C function (not
to a C++ one).

>
> Searching with Google didn't helped me:
> static int Tetra::StaticThreadProcGravity(void* pParam)
> {
>     return ((Tetra*)pParam)->ThreadGravity();
> }
>
> I still get an error.
>
> _______________________________________________
>  SDL mailing list
>  SDL at lists.libsdl.org
>  http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>


More information about the SDL mailing list