Discussion:
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
(too old to reply)
a***@gmail.com
2007-07-17 21:18:11 UTC
Permalink
fatal error C1189: #error : WINDOWS.H already included. MFC apps
must not #include <windows.h>

I am trying to create a DLL, but I need to use CString. What is a
work around this error?


Thanks
Victor Bazarov
2007-07-17 21:34:00 UTC
Permalink
Post by a***@gmail.com
fatal error C1189: #error : WINDOWS.H already included. MFC apps
must not #include <windows.h>
I am trying to create a DLL, but I need to use CString. What is a
work around this error?
If it says that MFC apps must not #include <windows.h>, don't include
it, include <afx...> stuff instead. Also, may I suggest the newsgroup

microsoft.public.vc.mfc

?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
SvenC
2007-07-17 21:34:41 UTC
Permalink
Hi,
Post by a***@gmail.com
fatal error C1189: #error : WINDOWS.H already included. MFC apps
must not #include <windows.h>
I am trying to create a DLL, but I need to use CString. What is a
work around this error?
When you create the project from the VC++ MFC wizard then CString should be
usable from the start.

Windows.h is a base header for Win32 development which is absolutely not the
defining "system" for CString.
CString comes from MFC and later on from ATL, as many people where using MFC
just to get CString.

So: how did you create the project?

--
SvenC
Giovanni Dicanio
2007-07-17 21:35:23 UTC
Permalink
Post by a***@gmail.com
fatal error C1189: #error : WINDOWS.H already included. MFC apps
must not #include <windows.h>
I am trying to create a DLL, but I need to use CString. What is a
work around this error?
Hi,

what version of the compiler are you using?

If you are using Visual C++ 7.1 or I think also VC++8, CString is now a
shared class between MFC and ATL. So you can use CString without using MFC.
You need to #include the ATL base header and CString header, if I recall
correctly that is:

#include <atlbase.h>
#include <atlstr.h>

so you can use CString.

If you are using VC6, you may copy-and-paste the CString header content and
maybe try to modify it and isolate it from MFC... or you may use C++
Standard Library std::string (for ANSI or Unicode UTF-8) or std::wstring
(for Unicode UTF-16) classes.

You may also typedef a TCHAR string e.g.:

typedef std::basic_string<TCHAR> tstring;

and use tstring instead of std::string or std::wstring.

G

Loading...