Inet_Pton': Identifier Not Found

inet_pton': identifier not found

the function

int inet_pton(int af, const char *src, void *dst);

is declared in header file:

#include <arpa/inet.h>

if this is Windows (Vista or later) there is Winsock analog to this ANSI version:

INT WSAAPI InetPton(
_In_ INT Family,
_In_ PCTSTR pszAddrString,
_Out_ PVOID pAddrBuf
);

try #include <Ws2tcpip.h>
add Ws2_32.lib

inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS

The ip string can be converted to the in_addr structure with the InetPton function.
It is used like this:

InetPton(AF_INET, strIP, &ipv4addr)

You need to include the "Ws2tcpip.h" header file, use the library "Ws2_32.lib" and DLL "Ws2_32.dll".

Deprecated commands in Visual C++

These errors are telling you what to do. Microsoft is nice like that.

gethostbyname -> getaddrinfo
inet_addr -> inet_pton
inet_ntoa -> inet_ntop

As far as GetVersionExW and GetVersion Microsoft recommends using the appropriate Version Helper Function.

windows equivalent of inet_aton

Windows supports inet_pton, which has a similar interface to inet_aton (but that works with IPV6 addresses too). Just supply AF_INET as the first parameter, and it will otherwise work like inet_aton.

(If you can change the Linux source, inet_pton will also work there).

Identifier not found error on function call

Add this line before main function:

void swapCase (char* name);

int main()
{
...
swapCase(name); // swapCase prototype should be known at this point
...
}

This is called forward declaration: compiler needs to know function prototype when function call is compiled.

getaddrinfo': identifier not found

Your headers are in the wrong order. #include "stdafx.h" should always be the first header include for a .c or .cpp file. (when using precompiled headedrs).

This is what's needed for stdafx.h:

#pragma once

#include "targetver.h"
#include <ws2tcpip.h> // includes <winsock2.h> implicitly which in turn includes <windows.h>
#include <stdlib.h>
#include <stdio.h>

This what's needed at the top of your main source file:

#include "stdafx.h"

// Need to link with Ws2_32.lib
#pragma comment (lib, "Ws2_32.lib")

#define DEFAULT_BUFLEN 512
#define DEFAULT_PORT "27015"

int __cdecl main(int argc, char **argv)
{
...


Related Topics



Leave a reply



Submit