我的程序创建了一个线程,但我在使用Visual Studio进行代码分析时得到了“不要使用C风格的强制转换”。
#include <windows.h>
#include <process.h>
#include <iostream>
void myThread(void * threadParams)
{
int* x = (int*)threadParams;
std::cout << "*x: " << *x;
}
int main()
{
BOOL bValue2 = TRUE;
_beginthread(myThread, 0, (LPVOID)&bValue2);
Sleep(10000);
}
我尝试了static_cast<LPVOID>&bValue2
,但它给出了一个错误。
在_beginthread
中转换的正确格式是什么?
1条答案
按热度按时间7uzetpgm1#
下面是一个例子: