c++( undeclared identifier)

来源:百度知道 编辑:UC知道 时间:2024/06/23 02:11:22
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include<process.h>
using namespace std;
#include"../dlib.h"
#pragma comment(lib,"..\\debug\\dlib.lib")

unsigned _stdcall s(LPVOID s)
{
Sleep(100);
return 0;
}

int main(int argc, char* argv[])
{
nDlib=0;
for(int i=0;i<4;i++)
{
nDlib++;
cout<<nDlib<<endl;

_beginthreadex(0,0,s,0,0,0);
Sleep(300);
}
return 0;
}

-Configuration: testdlib - Win32 Debug--------------------
Compiling...
testdlib.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\dlib\testdlib\testdlib.cpp(28) : error C2065: '_beginthreadex' : undeclared identifier
执行 cl.exe 时出错.

testdlib.exe - 1 error(s), 0 warning(s)
我是按照书上的例子打下来的,但是编译 就出问题了。不知哪里有问题。
我还有几点

参考答案:学到很多东西的诀窍,就是一下子不要学很多。——洛克

1.用_beginthreadex要有#include"process.h"的
2.如果用的是VC6还需要在工程属性->c/c++编译器选项卡中将默认的SingleThread(大概是这个)改为multiplethread(大概是这个)。

错误,'_beginthreadex' 没有声明,#include<process.h>加入这个头文件

<iostream>是c++加入的
using namespace std;是用于打开命名空间

<windows.h>C的

""是你自己建的文件,<>是编译器带的