#include <stdio.h>
#include <conio.h>
#include "stdafx.h"//后来添加的
int main()
{..........}
这个程序是一个类似于命令窗口的程序.我想在程序中添加对文件操作的类 CFile.于是我在上面的程序添加#include "stdafx.h",没有添加其他代码.然后编译出现错误.
fatal error C1189: #error :  MFC requires C++ compilation (use a .cpp suffix).

解决方案 »

  1.   

    #include "stdafx.h"//后来添加的         放到所有INCLUDE的最前面
      

  2.   

    致命错误 C1189#error : 用户提供的错误信息
    由程序中的 #error 指令生成。例如:
    // C1189.cpp
    #undef _WIN32#if !defined(_WIN32)
    #error _WIN32 must be defined   // C1189
    #endifint main() {
       return 0;
    }
    如果使用 /robust MIDL 编译器选项生成 ATL 项目,也有可能看到此错误。/robust 仅用于为 Windows 2000 或更高版本的计算机生成。因此,要么移除 /robust,要么将 dlldatax.c 文件中的此行:
    #define _WIN32_WINNT 0x0400   //for WinNT 4.0 or Win95 with DCOM
    更改为
    #define _WIN32_WINNT 0x0500   //for WinNT 4.0 or Win95 with DCOM