I am trying to make a thread in SDL. I have followed all the directions i can find online, but I i keep getting this error:
SDL\sample_profiler.cpp|72|error: invalid conversion from 'int' to 'int ()(void)' [-fpermissive]|
The following is my code for creating the thread:
void sample_profiler::run()
{
if (m_the_game_world->level_load())
{
SDL_Thread *l_thread;
l_thread = SDL_CreateThread(thread_run(m_the_game_world), "sample_thread",(void *)NULL);
}
}
The following is my function from my header file: int thread_run(void *p_the_game_world);
The problem is the first parameter of the function call SDL_CreateThread(). SDL_CreateThread() requires a function pointer. What you do is call the function and pass its result, which is int, as the first parameter.
This would be a correct call:
int Test( void* p )
{
return 0 ;
}
SDL_Thread* id = SDL_CreateThread( Test , "test" , ( void* )NULL );