2

I have a Visual Studio 6.0 project that uses SQL Compact Server. I'm trying to update the solution to use on Visual Studio 2012, but i have the following error:

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

My stdafx.h includes winsock2.h, who have this:

#ifndef _INC_WINDOWS
#include <windows.h>
#endif /* _INC_WINDOWS */

There is a way to supress the error? How do I proceed? When I remove the windows.h of the files that include it indirectly, I got error C2011: 'IRowsetBookmark' : 'struct' type redefinition

I already saw other questions here about this error, but none of suggestions works for me.


- update:

I solve the error C2011: 'IRowsetBookmark' : 'struct' type redefinition adding the following lines in the top of my stdafx.h:

#if !defined(__IRowsetBookmark_INTERFACE_DEFINED__)
#define __IRowsetBookmark_INTERFACE_DEFINED__
#endif

#if !defined(__IRowsetBookmark_FWD_DEFINED__)
#define __IRowsetBookmark_FWD_DEFINED__
#endif

But i got error C2143: syntax error : missing ',' before '<' On those line:

class CArrayRowset :
    public CVirtualBuffer<T>,
    public TRowset
{

Is it possible that adding that lines on my stdfx.h i messed up some class declaration?

suuuzi
  • 602
  • 1
  • 8
  • 19
  • 1
    Based on [this](http://stackoverflow.com/a/5027152/2802841), wouldn't including `afx.h` or `afxwin.h` just before including `winsock2.h` possibly solve the issue? – user2802841 Mar 21 '14 at 18:35
  • with this i got error C2011: 'IRowsetBookmark' : 'struct' type redefinition that i mentioned – suuuzi Mar 21 '14 at 18:40
  • As for the C2143, I think it's probably unrelated, isn't there an: `error C2504: 'CVirtualBuffer' : base class undefined` just before that? That would mean you have to include the file that defines it, which, at least on VS2013, seems to be `atldbcli.h`. – user2802841 Mar 21 '14 at 19:59
  • this error happens in atldbcli_ce.h – suuuzi Mar 21 '14 at 20:33

1 Answers1

1

try define _INC_WINDOWS before including winsock2.h to void including win.h

vlad_tepesch
  • 6,681
  • 1
  • 38
  • 80