开发者

_begintheadex function call problem

I have a class SoundManager which contains a function called 'recordLoop'. In the constructor of the SoundManager, I am using this code:

    recordHandle = (HANDLE)_beginthreadex(NULL,0,recordLoop,
        (void*)exinfo->length,CREATE_SUSPENDED,0);

It is giving me the following errors:

   error C3867: 'SoundManager::recordLoop': function call missing argument list; use '&SoundManager::recordLoop' to create a pointer to member
   IntelliSense: argument of type "unsigned int (__stdcall SoundManager::*)(void *params)" is incompatible with parameter of type "unsigned int (__stdcall *)(void *)"

So I've tried using the &SoundManager::开发者_如何学PythonrecordLoop as suggested, but it gives me this:

   error C2664: '_beginthreadex' : cannot convert parameter 3 from 'unsigned int (__stdcall SoundManager::* )(void *)' to 'unsigned int (__stdcall *)(void *)'
   IntelliSense: argument of type "unsigned int (__stdcall SoundManager::*)(void *params)" is incompatible with parameter of type "unsigned int (__stdcall *)(void *)"

Is it illegal to start a thread on a class method or did I do something wrong?

Thanks in advance

EDIT: Sorry forgot to add the recordLoop >.< here it is:

 public:
 unsigned __stdcall recordLoop(void* params);


It's illegal to start a thread on a non-static class member since there is no way for the created thread to know what this is.

What is the definition of recordLoop?


I had the same problem with casting. Ignoring all other problems like one mentioned in the answer above, function pointer must be cast to (unsigned(__stdcall*)(void*)) in _beginthreadex, no matter what type the function is or what is its parameter list.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜