你加了头文件<windows.h>了没?控制台是不使用windows的数据类型的。
解决方案 »
- 请教分配内存的区别:new、malloc、GlobalAlloc、LocalAlloc、HeapAlloc、VirtualAlloc
- CStdioFile对象读文件后计算字符串长度时把空格也算进去
- 请问在windows下如何发信号量让signal函数捕获
- 要使用全局钩子,因此首先构造全局钩子的载体--动态链接库 这句话对么?
- 利用Crecordset派生类处理大文本文件在SQL中读存问题求解?望不吝赐教
- 程序中用到了"winxp风格的按钮",中例子代码,在没有安装vc的环境下.就显示不出来了,哪位知道这样的代码用到了什么dll或者ocx文件??!!!
- 求要图示控件,比如柱状图显示之类的。
- atoi() 在程序运用时,有什么设置 。
- 大家来讨论捉BUG
- sql server连接报出错误
- 请问VC安装后其文件如xtree中的乱码问题如何解决?
- 问个关于vc-mfc的白痴问题
1>Deleting intermediate and output files for project 'multi_thread', configuration 'Debug|Win32'
1>Compiling...
1>multi_thread.cpp
1>.\multi_thread.cpp(3) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory1>Build log was saved at "file://d:\My Programs\multi_thread\multi_thread\Debug\BuildLog.htm"
1>multi_thread - 1 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========结果一样。
看起来VC++2005 express edition需要单独安装SDK,否则这些头文件都是没有的。
【程序】#include "iostream"
using namespace std;
#include "AFXWIN.H"UINT MyThreadProc( LPVOID pParam )
{
for (int i=5;i>=1;i--)
cout<<"Will terminate in "<<i<<"s\n"; exit(0); // thread completed successfully
}int main()
{
AfxBeginThread(MyThreadProc, 0);
for (int i=1;i<=10;i++)
cout<<"wait "<<i<<"s\n";
return 0;
}
【编译输出】1>------ Rebuild All started: Project: multi_thread, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'multi_thread', configuration 'Debug|Win32'
1>Compiling...
1>multi_thread.cpp
1>D:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\mfc\afxwin1.inl(1034) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\mfc\afxwin1.inl(1036) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Build log was saved at "file://d:\My Programs\multi_thread\multi_thread\Debug\BuildLog.htm"
1>multi_thread - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
project->settings->general Using MFC as a shared dll
放到 using namespace std的前面
【temporary solution】1、上面错误提示的原因是由于afxwin1.inl里对返回值的定义有误,修改之后该提示不再出现。2、接下来compile通过,但link出错。提示找不到nafxcw.lib,查了一下,这个lib应该是一个retail lib,express edition看来是不会有了。3、改为在Use of MFC 里使用Use MFC in a Shared DLL,compiler转而查找MFC42.lib和MFC42S.lib. express edition里依然没有。4、从VC6里面copy上述两个文件过来,问题解决。btw,试了一下,调整include的顺序后,问题依旧。【postscript】不知道这样创建线程有没有问题,感觉不应该查找MFC42。
由于使用了MFC42.lib和MFC42S.lib,全免费环境开发多线程程序的计划暂告失败。