hong pei
hong pei

Reputation: 929

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

I have a project that use stdafx.h as the precompile header. This means all the cpp file must contain #include "stdafx.h" as the first include.

However, in A.h, I will need to include "afxinet.h", but the compiler complain this

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

this is because "afxinet.h" complains when WINDOWS.H i included, but "stdafx.h" does have WINDOWS.H included and is present as the first include in A.cpp.

This implies that I need to somehow have "afxinet.h" included in front of "stdafx.h", but "stdafx.h" is the precompile header and needs to be present as the first include...

how can I resove this dilemma?

Upvotes: 0

Views: 12977

Answers (1)

user2383105
user2383105

Reputation:

If your project uses MFC, then you should include its headers in your stdafx.h and not use windows.h (as it will be included by MFC); and if you include windows.h, you cannot use MFC. afxinet.h is a part of MFC, so, I guess, you should either (1) replace your windows.h with afxwin.h and "use MFC" in settings (2) don't use MFC wrappers for WinInet, use functions from Wininet.h

Upvotes: 3

Related Questions