'Hints' 使用未定义的结构 - winSock
'Hints' uses undefined struct - winSock
我正在尝试使用 winsock 构建一个基本应用程序,但遇到了 运行 问题。我搜索了 google extensivliy 并查看了 MSDN 站点,但我似乎仍然无法解决这个问题。
错误:错误 C2079 'hints' 使用未定义的结构 '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...";
}
}
如有任何帮助,我们将不胜感激。
struct addrInfo
与 struct addrinfo
不是同一类型。您的程序使用第一个,headers 定义第二个。
我正在尝试使用 winsock 构建一个基本应用程序,但遇到了 运行 问题。我搜索了 google extensivliy 并查看了 MSDN 站点,但我似乎仍然无法解决这个问题。
错误:错误 C2079 'hints' 使用未定义的结构 '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...";
}
}
如有任何帮助,我们将不胜感激。
struct addrInfo
与 struct addrinfo
不是同一类型。您的程序使用第一个,headers 定义第二个。