Advertisement

CreateThread wrapper method

Started by December 20, 2002 09:40 PM
2 comments, last by Zyroth 21 years, 10 months ago
I can't quite seem to get this to work. I figure I pass a pointer to the function and then give that to the CreateThread function, and it should work right? Well... here's what I have now.
    
void CWindow::SpawnThread( void *functPtr )
{
	HANDLE hGameLoopThread;  // Main Thread handle

	DWORD tid;

	hGameLoopThread = CreateThread( 0, 0, functPtr, 0, 0, &tid);
}
    
And here's the error that I've been getting. Compiling... CWindow.cpp C:\Documents and Settings\Daniel Charette\Desktop\New builder\CWindow.cpp(147) : error C2664: 'CreateThread' : cannot convert parameter 3 from 'void *' to 'unsigned long (__stdcall *)(void *)' Conversion from 'void*' to pointer to non-'void' requires an explicit cast I know that it's probably just casting it into something else but I haven't been able to figure out what I should cast it to. I would really appriciate any idea's. I tried using an unsigned long and I even tried 'unsigned long (__stdcall *)(void *)' but of course this didn't work [edited by - zyroth on December 20, 2002 10:43:04 PM]
You can use the LPTHREAD_START_ROUTINE typedef which is defined in <windows.h>.

If I had my way, I''d have all of you shot! codeka.com - Just click it.

Advertisement
What he means is this:

hGameLoopThread = CreateThread( 0, 0, ( LPTHREAD_START_ROUTINE )functPtr, 0, 0, &tid);

Gamedev's AI Auto-Reply bot.
Thanks guys, I never would have found that on my own.

This topic is closed to new replies.

Advertisement