You may get compilation errors for afxsock.h

Build fails with the following errors :
Error 1 error C2065: 'IPPROTO_IPV6' : undeclared identifier c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/atlsocket.inl 130
Error 2 error C2065: 'SOCKADDR_STORAGE' : undeclared identifier c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 381
Error 3 error C2146: syntax error : missing ';' before identifier 'sockAddr' c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 381
Error 4 error C2065: 'sockAddr' : undeclared identifier c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 381
Error 5 error C2070: ''unknown-type'': illegal sizeof operand c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 382
Error 6 error C2070: ''unknown-type'': illegal sizeof operand c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 384
Error 7 error C2227: left of '->sin_port' must point to class/struct/union/generic type c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 394
Error 8 error C2146: syntax error : missing ';' before identifier 'sockAddr' c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 402
Error 9 error C2070: ''unknown-type'': illegal sizeof operand c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 403
Error 10 error C2070: ''unknown-type'': illegal sizeof operand c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 405
Error 11 error C2227: left of '->sin_port' must point to class/struct/union/generic type c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 415
Error 12 error C2146: syntax error : missing ';' before identifier 'sockAddr' c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 423
Error 13 error C2070: ''unknown-type'': illegal sizeof operand c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 424
Error 14 error C2070: ''unknown-type'': illegal sizeof operand c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 426
Error 15 error C2227: left of '->sin_port' must point to class/struct/union/generic type c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 436
Error 16 error C2146: syntax error : missing ';' before identifier 'sockAddrSelf' c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 450
Error 17 error C2065: 'sockAddrSelf' : undeclared identifier c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 450
Error 18 error C2070: ''unknown-type'': illegal sizeof operand c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 451
Error 19 error C2070: ''unknown-type'': illegal sizeof operand c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 453

Error 20 error C2228: left of '.ss_family' must have class/struct/union c:/program files (x86)/microsoft visual studio 8/vc/atlmfc/include/afxsock.h 470

原因:

Project has defined _WIN32_WINNT macro value less than minimum recommended for the Operating System, and Windows XP SP2 is minimum required for these structures. 
For example, if you set _WIN32_WINNT to 0x0500 or less, you will get the listed errors. 

解决办法:

Change the preprocessor definition to a version higher or equal to the minimum recommended.
See Using the Windows Headers for values to use.
If it is inherited from project defaults or parent project uncheck the following settings :
Project->Properties-> Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions->inherit from parent or project defaults.
转自 :http://support.microsoft.com/kb/950688

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值