gpt4 book ai didi

c++ - WinNt.h 编译错误

转载 作者:行者123 更新时间:2023-11-28 07:44:23 29 4
gpt4 key购买 nike

我在 Eclipse 中有一个新的 C++ 项目。我不得不手动添加所有包含路径,我一定是搞砸了。这是我的代码:

#include <winsock2.h>
int main() {
return 0;
}

我可以在 Visual Studio 中毫无问题地编译相同的代码,但在 Eclipse 中我会遇到许多各种各样的编译器错误。我忘了包括什么吗?还是我包含的太多了?有什么想法吗?

我确实也包含了 WS2_32 库。

我在 Windows 8 x64 上使用 msvc 2010 编译器。

我搜索了很长时间,但所有答案都是关于在包含 windows.h 之前包含 winsock,但我根本没有包含 windows.h。另外,这段完全相同的代码可以在 MSVC 中正确编译;因此,我在 Eclipse 中设置错误。

冒着被 tl;dr'ed 的风险,这里是 spew:

C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1243) : error C2065: 'SAL_sameIRQL' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1246) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1246) : error C2513: 'int' : no variable declared before '='
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1246) : error C2146: syntax error : missing ';' before identifier 'EXCEPTION_DISPOSITION'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1246) : error C2143: syntax error : missing ';' before '__stdcall'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1246) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1246) : error C2377: 'EXCEPTION_DISPOSITION' : redefinition; typedef cannot be overloaded with any other symbol
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\excpt.h(40) : see declaration of 'EXCEPTION_DISPOSITION'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1252) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1254) : error C2143: syntax error : missing ';' before '*'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1254) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1254) : error C2365: 'EXCEPTION_ROUTINE' : redefinition; previous definition was 'function'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1247) : see declaration of 'EXCEPTION_ROUTINE'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1254) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(10749) : error C2146: syntax error : missing ';' before identifier 'Handler'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(10749) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(10749) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(16638) : error C2144: syntax error : 'PSLIST_ENTRY' should be preceded by ','
C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(16646) : error C2144: syntax error : 'PSLIST_ENTRY' should be preceded by ','
C:\Program Files (x86)\Windows Kits\8.0\Include\um\heapapi.h(124) : error C2061: syntax error : identifier '_SA_annotes1'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\heapapi.h(125) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\heapapi.h(125) : error C2143: syntax error : missing ')' before ';'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\processthreadsapi.h(204) : error C2144: syntax error : 'LPVOID' should be preceded by ','
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(189) : error C2065: 'SAL_preferredFunction' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(192) : error C2448: '_SA_annotes2' : function-style initializer appears to be a function definition
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(192) : error C2143: syntax error : missing ';' before '__stdcall'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(351) : error C2065: 'COMPUTER_NAME_FORMAT' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(351) : error C2146: syntax error : missing ')' before identifier 'NameType'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(351) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(351) : error C2491: 'GetComputerNameExA' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(354) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(361) : error C2065: 'COMPUTER_NAME_FORMAT' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(361) : error C2146: syntax error : missing ')' before identifier 'NameType'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(361) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(361) : error C2491: 'GetComputerNameExW' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(364) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(383) : error C2065: 'COMPUTER_NAME_FORMAT' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(383) : error C2146: syntax error : missing ')' before identifier 'NameType'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(383) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(383) : error C2491: 'SetComputerNameExW' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.0\Include\um\sysinfoapi.h(385) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\memoryapi.h(429) : error C2065: 'MEMORY_RESOURCE_NOTIFICATION_TYPE' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\memoryapi.h(430) : error C2146: syntax error : missing ')' before identifier 'NotificationType'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\memoryapi.h(430) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.0\Include\um\memoryapi.h(430) : error C2491: 'CreateMemoryResourceNotification' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.0\Include\um\memoryapi.h(430) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\memoryapi.h(536) : error C2061: syntax error : identifier 'PWIN32_MEMORY_RANGE_ENTRY'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\threadpoolapiset.h(341) : error C2061: syntax error : identifier 'PTP_WIN32_IO_CALLBACK'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(54) : error C2061: syntax error : identifier 'BEM_FREE_INTERFACE_CALLBACK'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(64) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(64) : error C2143: syntax error : missing ',' before '*'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(73) : error C2065: 'BEM_REFERENCE' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(73) : error C2065: 'reference' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(74) : error C2065: 'BEM_REFERENCE' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(75) : error C2065: 'copiedReference' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(75) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(75) : error C2078: too many initializers
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(81) : error C2065: 'BEM_REFERENCE' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(82) : error C2065: 'reference' : undeclared identifier
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(82) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(82) : error C2182: 'BemFreeReference' : illegal use of type 'void'
C:\Program Files (x86)\Windows Kits\8.0\Include\um\bemapiset.h(82) : fatal error C1903: unable to recover from previous error(s); stopping compilation

最佳答案

如果可能,请尝试使用 7.1 或 7.0 SDK 而不是 8.0/8.1。我们在 8.0 SDK 中遇到了类似的问题。

关于c++ - WinNt.h 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15170546/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com