| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 822 人关注过本帖
标题:这段程序,为什么编译不能通过?
只看楼主 加入收藏
xzy199999
Rank: 4
等 级:业余侠客
帖 子:326
专家分:286
注 册:2010-11-19
结帖率:92.45%
收藏
已结贴  问题点数:20 回复次数:2 
这段程序,为什么编译不能通过?
#include "stdafx.h"
#include "conio.h"
#include "stdlib.h"
#include "string.h"
#include "windows.h"
#include "stdio.h"
#include <time.h>
#include <process.h>
unsigned Counter;
unsigned __stdcall SecondThreadFunc( void* pArguments )
{    printf( "In second thread...\n" );   
     while ( Counter < 1000000 )        
 Counter++;   
     _endthreadex( 0 );   
     return 0;}


void main()
{  HANDLE hThread;   
   unsigned threadID;   
   printf( "Creating second thread...\n" );    // Create the second thread.   
   hThread = (HANDLE)_beginthreadex( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID );   
   // Wait until second thread terminates. If you comment out the line   
// below, Counter will not be correct because the thread has not   
// terminated, and Counter most likely has not been incremented to   
// 1000000 yet.   
   WaitForSingleObject( hThread, INFINITE );   
   printf( "Counter should be 1000000; it is-> %d\n", Counter );    // Destroy the thread object.  
   CloseHandle( hThread );

}
为什么编译不能通过?提示D:\App_PC\12\12.cpp(17) : error C2065: '_endthreadex' : undeclared identifier
D:\App_PC\12\12.cpp(25) : error C2065: '_beginthreadex' : undeclared identifier
Error executing cl.exe.

12.exe - 2 error(s), 0 warning(s)
可是我不是已经包含process.h了么?怎么回事?
搜索更多相关主题的帖子: return 
2010-12-23 16:07
a343637412
Rank: 7Rank: 7Rank: 7
来 自:そ ら
等 级:黑侠
帖 子:357
专家分:620
注 册:2010-9-26
收藏
得分:0 
不会,
            借机学习,
...
2010-12-23 16:12
JZY0801
Rank: 2
等 级:论坛游民
帖 子:25
专家分:36
注 册:2010-12-23
收藏
得分:20 
你写的是多线程的程序,而编译器默认的是单线程的程序。
你可以在你的“工程”-->“设置”中改写一些!


图片附件: 游客没有浏览图片的权限,请 登录注册


将“Use run-time library”设置成截图中的形式就可以了!
2010-12-23 17:25
快速回复:这段程序,为什么编译不能通过?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025970 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved