gpt4 book ai didi

c++ - 在创建线程时无法理解此错误

转载 作者:可可西里 更新时间:2023-11-01 11:04:26 25 4
gpt4 key购买 nike

     HANDLE  hThread;
DWORD dwThreadId;

hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
MyThreadFunction, // thread function name
0, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier <--Debugger takes me to this line?

错误指定了第三个参数,但是当我双击错误时它会将我带到最后一个参数?
尝试运行 msdn CreateThread 示例 http://msdn.microsoft.com/en-us/library/ms682453%28VS.85%29.aspx

error C2664: 'CreateThread' : cannot convert parameter 3 from 'void (void)' to 'unsigned long (__stdcall *)(void *)'
None of the functions with this name in scope match the target type

最佳答案

调试器只是将您带到语句的末尾。

无论如何,你的函数签名是错误的,需要匹配函数指针类型。对于 CreateThread ,应该是:

DWORD WINAPI ThreadProc(LPVOID lpParameter);

关于c++ - 在创建线程时无法理解此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3087223/

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