gpt4 book ai didi

c++ - 没有重载函数 "AfxBeginThread"的实例与参数列表匹配

转载 作者:太空宇宙 更新时间:2023-11-04 12:11:09 25 4
gpt4 key购买 nike

我正在尝试使用 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);
}

但它给了我这个错误:

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

idk whats wrong it should be right!

最佳答案

来自 AfxBeginThread() 的文档您需要将第二个参数转换为 LPVOID:

AfxBeginThread(Test, (LPVOID) param);

并将Test的调用约定设置为__cdecl:

UINT __cdecl Test( LPVOID lParam)

关于c++ - 没有重载函数 "AfxBeginThread"的实例与参数列表匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9791648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com