我有一个类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);发布于 2011-01-13 01:26:25
在非静态类成员上启动线程是非法的,因为创建的线程无法知道this是什么。
recordLoop的定义是什么
发布于 2015-03-27 12:35:21
我在选角时也遇到了同样的问题。忽略上面答案中提到的所有其他问题,无论函数是什么类型或其参数列表是什么,都必须将函数指针强制转换为_beginthreadex中的(unsigned(__stdcall*)(void*))。
https://stackoverflow.com/questions/4671827
复制相似问题