你加了头文件<windows.h>了没?控制台是不使用windows的数据类型的。

解决方案 »

  1.   

    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>.\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 ==========结果一样。
      

  2.   

    错误的直接原因是缺少一些类型定义,这些定义在windef.h里面,包含windows.h就可以。编译器提示找不到windows.h,看一下你的VC路径设置里面include的路径设置是否正确,再看一下windows.h是不是丢失了或者被破坏了无法打开。
      

  3.   

    把这句话#include "afxwin.h"加入stdafx.h文件中了没?
      

  4.   


    看起来VC++2005 express edition需要单独安装SDK,否则这些头文件都是没有的。
      

  5.   

    原来是2005 express edition,没用过。
      

  6.   

    安装了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 ==========
      

  7.   

    #include "afxwin.h"
    project->settings->general Using MFC as a shared dll
      

  8.   

    #include "afxwin.h"
    放到 using namespace std的前面
      

  9.   


    【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,全免费环境开发多线程程序的计划暂告失败。