_stdcall的说明及error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' t
2012-10-21 16:09
573 查看
(转)
用VC创建新线程易出的问题error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'
解决方案:
(1)如果线程要执行的是类的成员函数,则必须用static声明为静态函数
如:
class echo
{
static DWORD WINAPI ThreadFunc(LPVOID pvoid)
......
......
}
(2)一般都是调用全局函数.
我们在用CreateThread(NULL,0,ThreadProc,NULL,0,NULL)创建线程得时候,此函数中需要新线程中的函数地址,我们常用的有两种方法解决:
一.将我们要调用的新线程函数声明成DWORD WINAPI ThreadProc(lpvoid lpParameter)。
二.我们可以将新线程函数声明成类中的成员函数:static DWORD WINAPI ThreadProc(lpvoid lpParameter)
但是当我们的写法不正确的时候,往往会出现error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)' 这个问题
//////////////////////////////////////////////////////////////////////////////
__stdcall是函数调用约定的一种,函数调用约定主要约束了两件事:
1.参数传递顺序
2.调用堆栈由谁(调用函数或被调用函数)清理
常见的函数调用约定:stdcall
cdecl fastcall thiscall naked call
__stdcall表示
1.参数从右向左压入堆栈
2.函数被调用者修改堆栈
3.函数名(在编译器这个层次)自动加前导的下划线,后面紧跟一个@符号,其后紧跟着参数的尺寸
在win32应用程序里,宏APIENTRY,WINAPI,都表示_stdcall,非常常见。
(百度百科)
用VC创建新线程易出的问题error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'
解决方案:
(1)如果线程要执行的是类的成员函数,则必须用static声明为静态函数
如:
class echo
{
static DWORD WINAPI ThreadFunc(LPVOID pvoid)
......
......
}
(2)一般都是调用全局函数.
我们在用CreateThread(NULL,0,ThreadProc,NULL,0,NULL)创建线程得时候,此函数中需要新线程中的函数地址,我们常用的有两种方法解决:
一.将我们要调用的新线程函数声明成DWORD WINAPI ThreadProc(lpvoid lpParameter)。
二.我们可以将新线程函数声明成类中的成员函数:static DWORD WINAPI ThreadProc(lpvoid lpParameter)
但是当我们的写法不正确的时候,往往会出现error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)' 这个问题
//////////////////////////////////////////////////////////////////////////////
__stdcall是函数调用约定的一种,函数调用约定主要约束了两件事:
1.参数传递顺序
2.调用堆栈由谁(调用函数或被调用函数)清理
常见的函数调用约定:stdcall
cdecl fastcall thiscall naked call
__stdcall表示
1.参数从右向左压入堆栈
2.函数被调用者修改堆栈
3.函数名(在编译器这个层次)自动加前导的下划线,后面紧跟一个@符号,其后紧跟着参数的尺寸
在win32应用程序里,宏APIENTRY,WINAPI,都表示_stdcall,非常常见。
(百度百科)
相关文章推荐
- 用VC创建新线程易出的问题error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall
- (菜鸟级别)解决用VC创建新线程易出的问题error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (_
- error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'
- 调用创建线程函数时出现'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned lo
- cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *
- 报错 error C2664: 'CreateWindowExA' : cannot convert parameter 2 from 'unsigned short [10]' to 'const char *'
- cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *
- CreateThread 函数常见错误 cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long...
- 多线程问题cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *
- CreateThread 函数常见错误 cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *
- CreateThread 函数常见错误 cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__st
- error C2664: 'CWnd::FromHandle' : cannot convert parameter 1 from 'unsigned long' to 'HWND'
- error C2664: 'RtCreateTimer' : cannot convert parameter 3 from 'int (void *)' to 'void (__stdcall *)(void *)'问题解决办法
- error C2440: 'initializing' : cannot convert from 'unsigned long' to 'void *
- error C2664: 'cvSetMouseCallback' : cannot convert parameter 2 from 'void (int,int,int,int,void *)'
- error C2664: 'int CListCtrl::InsertColumn(int,LPCTSTR,int,int,int)' : cannot convert parameter 2 from 'const char [7]' to 'LPCTS
- 关于VS2005的error C2664: cannot convert parameter 2 from 'const char [2]' to 'LPCWSTR
- parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)VC以类的成员函数作为线程调用函数时易出错问题解决办法
- error C2664: 'cvSetMouseCallback' : cannot convert parameter 2 from ....to'CvMouseback'
- 错误 1 error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [17]' to 'LPCTST