Click to See Complete Forum and Search --> : error with afxinet.h and windows.h (error c1189)
cuiky
December 27th, 2004, 06:45 AM
hello..
i have an error in my atl application when included file afxinet.h. This application is an OPC Client that is waiting for data from a OPC Server. When data is updated i wake up one thread to connect with a web that return a result of a SQL.
My problem is that when i included file afxinet.h this error appear:
"fatal error c1189: #error: WINDOWS.H already included...."
i'm not included "windows.h"...only my own .h and afxinet.h
what is the solution??
P.D: I'm so sorry for my bad english
NoHero
December 27th, 2004, 07:14 AM
If you include any MFC header you do not need any other SDK headers. So remove all includes of winsock2.h and/or windows.h. If you still can't find the error, you should post the full code, and point us to the line where the error happens.
cuiky
December 27th, 2004, 07:35 AM
this is my code (only includes):
-> stdafx.h
...
#include "resource.h"
#include <atlbase.h>
#include <atlcom.h>
using namespace ATL;
->OpcClient.cpp
#include "stdafx.h"
#include "OpcClient.h" // Generated throw MIDL
#include "global.h"
-> my_main.cpp
#include "stdafx.h"
#include "OpcClient.h" // Generated throw MIDL
#include "OpcClient_i.c" // Generated throw MIDL
#include "CimplicityConnect.h"
#include "global.h"
#include <fcntl.h>
#include <io.h>
-> CimplicityConnect.cpp
#include "stdafx.h"
#include "OPCDA.h" // Generated throw MIDL
#include "opcda_i.c" // Generated throw MIDL
#include "CimplicityConnect.h"
#include "OPCDataCallback.h"
#include "global.h"
-> OPCDataCallback.cpp
#include "stdafx.h"
#include "OPCDataCallback.h"
#include "global.h"
-> web_access.cpp
#include "stdafx.h"
#include "web_access.h"
#include <afxinet.h> -> this is my problem
when i included afxinet.h in the file web_access.cpp start the error...if comment this line i can't use classes cinternetsesion, chttpconection, etc..
Ajay Vijay
December 27th, 2004, 07:43 AM
Put #include<afxinet.h> within the stdafx.h itself before all header includes. You may need to shift down this file in headers include (in stdafx.h), if you get some other errors.
cuiky
December 28th, 2004, 03:22 AM
i put afxinet.h in stdafx.h and begin to shift down...if #include <afxinet.h> is BEFORE #include <atlbase.h> i have that errors:
--> opcclient.cpp (file with main)
....
class COpcClientModule : public CAtlExeModuleT< COpcClientModule >
{
public :
......
unknow the class CAtlExeModuleT
--> web_access.cpp (file using CInternetSession, etc..)
cerr, endl and cout not declared or not found
if i put #include <afxinet.h> AFTER the initial error of windows.h return
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.