我正在使用Qt Creator和MinGW。
我包含了“windows.h”并编译它,但它失败了。错误如下:
In file included from c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/windows.h:98:0,
from util/IdleDetector.h:8,
from service\PresenceService.cpp:8:
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/winsock2.h:771:22: error: expected unqualified-id before string constant
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/winsock2.h:1034:95: error: expected identifier before string constant
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/winsock2.h:1034:95: error: expected ',' or '...' before string constant
我认为MinGW路径丢失了,但事实并非如此。我该如何解决这个问题?
答案 0 :(得分:0)
windows.h
是winsock.h
还是winsock2.h
?两者互不兼容。 winsock2.h
旨在取代winsock.h
,因此重新声明winsock.h
已经声明的很多内容。如果winsock2.h
之前包含winsock.h
,则winsock2.h
会默默禁用winsock.h
,一切正常。但如果winsock.h
之前包含winsock2.h
,则可能会发生各种错误。