0

我是Visual C++新手。我在Windows XP中安装了Visual C++ 2008 Express Edition(带有SP1)。我正在尝试编译一个开源的Visual C++项目。如何将ws2tcpip.h和ws2def.h包含到Visual C++ 2008项目中?

我已经在VC++ 2008 Express中打开了.vcproj项目。当我使用生成>重建解决方案,它显示下面的输出:

3 error(s) 
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== 

下面是3个错误:

error C3861: 'IN6_IS_ADDR_MULTICAST': identifier not found 

error C2065: 'IPPROTO_IPV6' : undeclared identifier 

error C2065: 'IPPROTO_IPV6' : undeclared identifier 

我一直在google搜索了很长的时间。我发现,这些标识在以下文件:

  • ws2tcpip.h

  • ws2def.h

  • winsock2.h

如果我没有记错的话,这些文件被使用Windows开发人员可以做网络/套接字编程。它应该在Windows的某个地方可用。

我可以知道error C2065: undeclared identifiererror C3861: identifier not found之间的区别吗?

如何将ws2tcpip.hws2def.h包含到Visual C++ 2008项目中?

谢谢

回答

1

它是否像#include在适当的文件中包含这些标头?

#include <winsock2.h> 
#include <ws2tcpip.h> 

注意winsock2.h必须在 ws2tcpip.h进行#included ,否则你会得到像编译错误“ip_mreq :: imr_multiaddr使用未定义STRUC组in_addr”和“字节是不是in6_addr成员:: __未命名”。

相关问题