1

I use in my project a lot of includes (but every header file use header guards like

#ifndef _HEADER_H 
#define _HEADER_H
...
#endif

and now I'm getting this errors from ws2ipdef.h (automatically included of windows.h):

c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(336) : error C2146: syntax error : missing ';' before identifier 'IN6_ADDR_EQUAL'
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(336) : error C2433: 'Boolean' : 'inline' not permitted on data declarations
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(336) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(337) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(344) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(344) : warning C4508: 'IN6_ADDR_EQUAL' : function should return a value; 'void' return type assumed
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(354) : error C2146: syntax error : missing ';' before identifier 'IN6_IS_ADDR_UNSPECIFIED'
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(354) : error C2433: 'Boolean' : 'inline' not permitted on data declarations
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(354) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(354) : error C2086: 'int Boolean' : redefinition
1>        c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(336) : see declaration of 'Boolean'
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(355) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(367) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(367) : warning C4508: 'IN6_IS_ADDR_UNSPECIFIED' : function should return a value; 'void' return type assumed

In Interface.h (is included in some other files) I use:

#define WIN32_LEAN_AND_MEAN

// sockets
#include <winsock2.h>
#include "windows.h"
#include <ws2tcpip.h>

How can I resolve this issue or any hints?

Thx

leon22
  • 5,280
  • 19
  • 62
  • 100
  • 1
    i believe it is supposed to be #include , not #include "windows.h" – jondinham Nov 14 '12 at 10:05
  • Probably some stupid rule of having to include first. And as for this stupid compiler error: "error C4430: missing type specifier - int assumed. Note: C++ does not support default-int", when are Microsoft going to change this to something more meaningful. `error C4430: missing type specifier will suffice, and "shut up" about int. As you say, C++ does not support it. So don't put it in the error message. – CashCow Nov 14 '12 at 10:13
  • If I comment the winsock, windows and ws2tcpip header files (+ inherent code) I have no errors! – leon22 Nov 14 '12 at 12:36

2 Answers2

0

Try using #pragma once instead of of ifndef guard, it specifies that the file will be included (opened) only once by the compiler when compiling a source code file. http://msdn.microsoft.com/en-us/library/4141z1cx.aspx

Matt
  • 6,010
  • 25
  • 36
0

Solved it with an additional ifndef guard in Interface.h

#ifndef _READERCOMMUNICATION_H
#define WIN32_LEAN_AND_MEAN // to exlude some unnecessary windows headers (see windows.h)

// sockets
//#include <winsock2.h> // winsock 1 is enough for my project
#include <windows.h>
#include <ws2tcpip.h>
#endif 
leon22
  • 5,280
  • 19
  • 62
  • 100