我有一个SoundManager类,其中包含一个名为“ recordLoop”的函数。在SoundManager的构造函数中,我正在使用以下代码:
recordHandle = (HANDLE)_beginthreadex(NULL,0,recordLoop,
(void*)exinfo->length,CREATE_SUSPENDED,0);
它给了我以下错误:
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 *)"
因此,我尝试按照建议使用&SoundManager :: recordLoop,但是它给了我这个:
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 *)"
在类方法上启动线程是非法的,还是我做错了什么?
提前致谢
编辑:对不起忘了添加recordLoop>。
public:
unsigned __stdcall recordLoop(void* params);
最佳答案
在非静态类成员上启动线程是非法的,因为创建的线程无法知道this
是什么。recordLoop
的解释是什么?