Visual C++

Moderators: Lundin
Number of threads: 373
Number of posts: 687

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
fatal error C1189: #error: WINDOWS.H already included. Posted by diyora on 5 May 2008 at 10:25 PM
Hello all,

My stdafx.h file contain:

#pragma once

// 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 XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#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 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

My abc.h file contain:

#include <afxwin.h>
#include <stdio.h>
#include <winsock2.h>
#include <conio.h>
#include <iostream>
using namespace std;

class CIPMessage
{
public:
CIPMessage();
~CIPMessage();
void Init(string sIpAddress, int iPort);
int SendMessagePort(string sMessage);
int RecMessagePort();
bool IsConnected(){return m_bIsConnected;}
private:
bool m_bIsConnected; // true - connected false - not connected
string m_sServerIPAddress;
int m_iServerPort;
SOCKET conn; // socket connected to server
};

I define this both header file in my main source file.But it give me an error:
c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxv_w32.h(16) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>.

I see the related question and change corresponds.but it give me error.When i remove the windows.h then write afxwin.h then main source file some variable undeclared identifier.

please help me..


Report
Re: fatal error C1189: #error: WINDOWS.H already included. Posted by AsmGuru62 on 6 May 2008 at 4:04 AM
: Hello all,
:
: My stdafx.h file contain:
:
: #pragma once
:
: // 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 XP or
: later.
: #define WINVER 0x0501 // Change this to the appropriate value to
: target other versions of Windows.
: #endif
: #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP
: or later.
: #define _WIN32_WINNT 0x0501 // Change this to the appropriate value
: to target other versions of Windows.
: #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 6.0 or
: later.
: #define _WIN32_IE 0x0600 // Change this to the appropriate value to
: target other versions of IE.
: #endif
: #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from
: Windows headers
: // Windows Header Files:
: #include <windows.h>
: // C RunTime Header Files
: #include <stdlib.h>
: #include <malloc.h>
: #include <memory.h>
: #include <tchar.h>
:
: My abc.h file contain:
:
: #include <afxwin.h>
: #include <stdio.h>
: #include <winsock2.h>
: #include <conio.h>
: #include <iostream>
: using namespace std;
:
: class CIPMessage
: {
: public:
: CIPMessage();
: ~CIPMessage();
: void Init(string sIpAddress, int iPort);
: int SendMessagePort(string sMessage);
: int RecMessagePort();
: bool IsConnected(){return m_bIsConnected;}
: private:
: bool m_bIsConnected; // true - connected false - not connected
: string m_sServerIPAddress;
: int m_iServerPort;
: SOCKET conn; // socket connected to server
: };
:
: I define this both header file in my main source file.But it give me
: an error:
: c:\program files\microsoft visual studio
: 8\vc\atlmfc\include\afxv_w32.h(16) : fatal error C1189: #error :
: WINDOWS.H already included. MFC apps must not #include <windows.h>.
:
: I see the related question and change corresponds.but it give me
: error.When i remove the windows.h then write afxwin.h then main
: source file some variable undeclared identifier.
:
: please help me..
:
If your code is MFC code, then remove include for WINDOWS.H and leave the STDAFX.H. If your code is pure WIn32 API, then do the opposite.

Post the errors you have - which identifier becomes undeclared?
Report
Re: fatal error C1189: #error: WINDOWS.H already included. Posted by diyora on 6 May 2008 at 4:29 AM
: : Hello all,
: :
: : My stdafx.h file contain:
: :
: : #pragma once
: :
: : // 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 XP or
: : later.
: : #define WINVER 0x0501 // Change this to the appropriate value to
: : target other versions of Windows.
: : #endif
: : #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP
: : or later.
: : #define _WIN32_WINNT 0x0501 // Change this to the appropriate value
: : to target other versions of Windows.
: : #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 6.0 or
: : later.
: : #define _WIN32_IE 0x0600 // Change this to the appropriate value to
: : target other versions of IE.
: : #endif
: : #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from
: : Windows headers
: : // Windows Header Files:
: : #include <windows.h>
: : // C RunTime Header Files
: : #include <stdlib.h>
: : #include <malloc.h>
: : #include <memory.h>
: : #include <tchar.h>
: :
: : My abc.h file contain:
: :
: : #include <afxwin.h>
: : #include <stdio.h>
: : #include <winsock2.h>
: : #include <conio.h>
: : #include <iostream>
: : using namespace std;
: :
: : class CIPMessage
: : {
: : public:
: : CIPMessage();
: : ~CIPMessage();
: : void Init(string sIpAddress, int iPort);
: : int SendMessagePort(string sMessage);
: : int RecMessagePort();
: : bool IsConnected(){return m_bIsConnected;}
: : private:
: : bool m_bIsConnected; // true - connected false - not connected
: : string m_sServerIPAddress;
: : int m_iServerPort;
: : SOCKET conn; // socket connected to server
: : };
: :
: : I define this both header file in my main source file.But it give me
: : an error:
: : c:\program files\microsoft visual studio
: : 8\vc\atlmfc\include\afxv_w32.h(16) : fatal error C1189: #error :
: : WINDOWS.H already included. MFC apps must not #include <windows.h>.
: :
: : I see the related question and change corresponds.but it give me
: : error.When i remove the windows.h then write afxwin.h then main
: : source file some variable undeclared identifier.
: :
: : please help me..
: :
: If your code is MFC code, then remove include for
: WINDOWS.H and leave the STDAFX.H. If your code is pure WIn32 API,
: then do the opposite.
:
: Post the errors you have - which identifier becomes
: undeclared?



I am beginner in VC++.My code in Win32.Please tell me the changes which requires..

Report
Re: fatal error C1189: #error: WINDOWS.H already included. Posted by Lundin on 6 May 2008 at 5:50 AM
: : If your code is MFC code, then remove include for
: : WINDOWS.H and leave the STDAFX.H. If your code is pure WIn32 API,
: : then do the opposite.

:
: I am beginner in VC++.My code in Win32.Please tell me the changes
: which requires..
:


He just did that.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.