error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

http://ghyan1208.blog.163.com/blog/static/162866676201072511746382/

错误原因主要是因为#include <afx.h>这句的位置不对,应该放在第一行。在每一个.cpp或.h里面都应该是第一行。
 
: fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
我是在windows console下编译  枚举局域网主机名及其ip   的时候遇到这个问题的
 
#include "winsock2.h "
#include <afx.h>//因为要用到CString所以要包含这个头文件
#include <iostream>
using namespace std;
 
后来把头文件包含位置换了下  编译通过
 
#include <afx.h>//因为要用到CString所以要包含这个头文件
#include "winsock2.h "
#include <iostream>
using namespace std;
 
posted on 2011-12-14 10:19  justiner  阅读(2995)  评论(0编辑  收藏  举报