简体   繁体   English

没有重载的实例 function “AfxBeginThread” 与参数列表匹配

[英]no instance of overloaded function "AfxBeginThread" matches the argument list

am trying to make a worker thread using MFC so here is the codes:我正在尝试使用 MFC 创建一个工作线程,所以这里是代码:

struct ThreadParam
{
    HWND mDlg;    // Note: A handle.
};

UINT TestMFCThread::Test( LPVOID pParam ){
  //do work!
}
void TestMFCThread::OnBnClickedButton2()
{
    ThreadParam* param = new ThreadParam;
    param->mDlg = m_hWnd;
    AfxBeginThread(Test, param);
}

but it gives me this error:但它给了我这个错误:

1   IntelliSense: no instance of overloaded function "AfxBeginThread" matches the argument list
    argument types are: (UINT (LPVOID pParam), ThreadParam *)

idk whats wrong it's supposed to be right! idk 怎么了它应该是正确的!

From the documentation for AfxBeginThread() you need to cast the second argument to LPVOID : AfxBeginThread()的文档中,您需要将第二个参数强制转换LPVOID

AfxBeginThread(Test, (LPVOID) param);

and set calling convention of Test to __cdecl : 并将Test调用约定设置为__cdecl

UINT __cdecl Test( LPVOID lParam)

just declare your member function as static, it will solve the issue只需将您的成员 function 声明为 static,即可解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有重载函数“搜索”的实例与参数列表匹配 - no instance of overloaded function “search” matches the argument list 没有重载函数“stoi”的实例与参数列表匹配 - no instance of overloaded function "stoi" matches the argument list 没有重载 function AddSnapshotListener 的实例与参数列表匹配 - no instance of overloaded function AddSnapshotListener matches the argument list 没有重载函数findcontours的实例与参数列表匹配 - No instance of overloaded function findcontours matches the argument list 没有重载函数“”的实例与参数列表错误匹配 - no instance of overloaded function “” matches the argument list error 没有重载 function “strstr”实例与参数列表匹配 - no instance of overloaded function “strstr” matches the argument list 没有重载函数的实例“getline”匹配参数列表 - no instance of overloaded function “getline” matches argument list 没有重载函数的实例与参数列表匹配。 - No instance of overloaded function matches argument list. C ++没有重载函数getline的实例匹配参数列表 - C++ No instance of overloaded function getline matches argument list 多个重载函数实例与参数列表匹配 - more than one instance of overloaded function matches the argument list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM