Ronnie Smith

I have looked through the other posts concerning this error and I am sure that this situation is different.

I have a C++ COM ATL project and am trying to use CStringList which resides in <afxcoll.h>

But when I include <afxcoll.h>

#include "stdafx.h"
#include <afxcoll.h>

I get the error:

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

I'd be very grateful for any help. By the way the stdafx.h file looks like this:

#pragma
once
#ifndef
STRICT
#define STRICT
#endif

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.

#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
#endif

#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif

#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit

// turns off ATL's hiding of some common and often safely ignored warning messages

#define _ATL_ALL_WARNINGS
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>

using namespace ATL;






 



Re: Visual C++ General C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

Sridhar Madhugiri MSFT

Hi,

Include the header before the atl headers in stdafx.h.

#include <afxcoll.h>
#define _ATL_ALL_WARNINGS
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>

using namespace ATL;

Sridhar Madhugiri
Software Developer
Visual C++






Re: Visual C++ General C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

JetDog



I need a happier one of these emotions to express my gratitude. AMAZING job. Now, if only I knew this three hours ago I wouldn't have been up until the next morning ;>





Re: Visual C++ General C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

UshaChengan

Hi guys,

Can anyone help me solve the following error:

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

I am trying to create "Shared Add-in" project in Visual Studio 2005.

When I include <afxwin.h> in my connect.cpp file, I get the above error. I don't understand why it is occuring.

Can anyone help me to sovle this

Thanks in advance,

Usha.





Re: Visual C++ General C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

Bilal Haider

thanx man! it worked!
but what type of bull shitttt is it