简体   繁体   English

'提示'使用未定义的结构-winSock

[英]'Hints' uses undefined struct - winSock

I am trying to build a basic application with winsock and I have ran into a problem. 我试图用Winsock构建一个基本应用程序,但遇到了问题。 I have search through google extensivliy and took a look at the MSDN site but I still seem to be unable to solve this issue. 我已经通过google可扩展性进行搜索,并查看了MSDN网站,但是我似乎仍然无法解决此问题。

ERROR: Error C2079 'hints' uses undefined struct 'addrInfo' 错误: 错误C2079“提示”使用未定义的结构“ addrInfo”

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#pragma once
#include <iostream> 
#include <windows.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>   
#include "string.h"
#pragma comment(lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib") 
#pragma comment (lib, "AdvApi32.lib")


 int main()
 {
  int _iResult;
  struct addrInfo *result = NULL, *ptr = NULL, hints;
  _iResult = WSAStartup(MAKEWORD(2,2), &_wsaData);

  if(_iResult == 0)
  {
     ZeroMemory(&hints, sizeof(hints));
     hints.ai_family = AF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
     hints.ai_protocol = IPPROTO_TCP;
     return "Window Socket DLL loaded...";
  }
  else
  {
     return "Failed to Window Socket DLL loaded...";
  }

 }

Any help would be appreciated. 任何帮助,将不胜感激。

struct addrInfo is not the same type as struct addrinfo . struct addrInfostruct addrinfo类型不同。 Your program uses the first, the headers define the second. 您的程序使用第一个,标题定义第二个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM