C++ _BegineAdex函数调用问题
我有一个SoundManager类,它包含一个名为“recordLoop”的函数。在SoundManager的构造函数中,我使用以下代码:C++ _BegineAdex函数调用问题,c++,multithreading,winapi,class,visual-studio-express,C++,Multithreading,Winapi,Class,Visual Studio Express,我有一个SoundManager类,它包含一个名为“recordLoop”的函数。在SoundManager的构造函数中,我使用以下代码: recordHandle = (HANDLE)_beginthreadex(NULL,0,recordLoop, (void*)exinfo->length,CREATE_SUSPENDED,0); 它给了我以下错误: error C3867: 'SoundManager::recordLoop': function c
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);
在非静态类成员上启动线程是非法的,因为创建的线程无法知道该是什么
recordLoop
的定义是什么?在非静态类成员上启动线程是非法的,因为创建的线程无法知道该是什么
记录循环的定义是什么?我在铸造方面也有同样的问题。
忽略上面答案中提到的所有其他问题,无论函数是什么类型或其参数列表是什么,函数指针都必须强制转换到beginthreadex中的(unsigned(u stdcall*)(void*))
。我也有同样的强制转换问题。
忽略上面答案中提到的所有其他问题,函数指针必须强制转换为_beginthreadex中的(unsigned(u stdcall*)(void*))
,无论函数是哪种类型或它的参数列表是什么。recordloop函数是静态的,它以void*作为参数吗?recordloop函数是静态的,它以void*作为参数吗?我明白了。谢谢你的礼物!我懂了。谢谢你的礼物!