Page 1 of 1

Error compiling 1418

Posted: Fri Aug 21, 2015 5:05 pm
by jimm0thy
Two days ago I downloaded the source from SVN and attempted to compile in VS2013, however the below error occurs for socketaddress.cpp

Code: Select all

socketaddress.cpp(126): error C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
1>          c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(1868) : see declaration of 'inet_ntoa'
Below is lines 123 - 133 of socketaddress.cpp

Code: Select all

#else
    if (addr.sa_family == AF_INET) {
        if (include_port)
            sprintf(addr_str, "%s:%d", inet_ntoa(((struct sockaddr_in *)&addr)->sin_addr), GetPort());
        else
            sprintf(addr_str, "%s", inet_ntoa(((struct sockaddr_in *)&addr)->sin_addr));
        return addr_str;
    }

    return "< IPv6 in early versions of Windows not supported! >";
#endif

I've tried compiling this on both a Windows 10 machine and Windows 7 machine , both 64bit. I was able to get it to compile by editing the last few lines of socketaddress.cpp to the below (which is just a copy of the code from above it at the start of the if/then statement).
I program in vb.net and can follow C# and Java to some extent, but C++ not so much.

Code: Select all

#else
	char buf[sizeof(addr_str)];
    if (addr.sa_family == AF_INET) {
        if (include_port)
            sprintf(addr_str, "%s:%d", inet_ntop(AF_INET, &((struct sockaddr_in *)&addr)->sin_addr, buf, sizeof(buf)), GetPort()); // was inet_ntoa
        else
            sprintf(addr_str, "%s", inet_ntop(AF_INET, &((struct sockaddr_in *)&addr)->sin_addr, buf, sizeof(buf))); // was inet_ntoa
        return addr_str;
    }

    return "< IPv6 in early versions of Windows not supported! >";
#endif
Just wanted to throw that out there, maybe theres something I'm missing, but I have been able to compile and set the VGO server.
Which brings me to something else I noticed, with the vgo-world.xml file. The server settings in the file ask for externalIP= , however using this I can never fully connect to my server (hangs at waiting for data). Leaving the externalIP empty works for local connections, and changing externalIP= completely to worldaddress= seems to work just fine

Re: Error compiling 1418

Posted: Sat Aug 22, 2015 8:51 pm
by jimm0thy
With some testing I found that my compiled code change wasn't allowing external connections. However changing it to the below (basically removing the If / Then statement without actually removing it) it now accepts external connections.
Though the default code from svn still will not compile for me due to the above error.
This also allowed me to set the vgo-world.xml back to using externalIp= , so doubt the worldaddress= in its place was doing anything.

Code: Select all

const char * SocketAddress::ToString(bool include_port) {
#if !defined(_WIN32) || (defined(NTTDI_VERSION) && NTTDI_VERSION >= NTDDI_VISTA)
	char buf[sizeof(addr_str)];
    if (addr.sa_family == AF_INET) {
        if (include_port)
            sprintf(addr_str, "%s:%d", inet_ntop(AF_INET, &((struct sockaddr_in *)&addr)->sin_addr, buf, sizeof(buf)), GetPort());
        else
            sprintf(addr_str, "%s", inet_ntop(AF_INET, &((struct sockaddr_in *)&addr)->sin_addr, buf, sizeof(buf)));
    }
    else {
        if (include_port)
            sprintf(addr_str, "%s:%d", inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&addr)->sin6_addr, buf, sizeof(buf)), GetPort());
        else
            sprintf(addr_str, "%s", inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&addr)->sin6_addr, buf, sizeof(buf)));
    }

    return addr_str;
#else
	char buf[sizeof(addr_str)];
	if (addr.sa_family == AF_INET) {
		if (include_port)
			sprintf(addr_str, "%s:%d", inet_ntop(AF_INET, &((struct sockaddr_in *)&addr)->sin_addr, buf, sizeof(buf)), GetPort());
		else
			sprintf(addr_str, "%s", inet_ntop(AF_INET, &((struct sockaddr_in *)&addr)->sin_addr, buf, sizeof(buf)));
	}
	else {
		if (include_port)
			sprintf(addr_str, "%s:%d", inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&addr)->sin6_addr, buf, sizeof(buf)), GetPort());
		else
			sprintf(addr_str, "%s", inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&addr)->sin6_addr, buf, sizeof(buf)));
	}

    return "< IPv6 in early versions of Windows not supported! >";
#endif

Re: Error compiling 1418

Posted: Sun Aug 23, 2015 9:27 am
by John Adams
This is very strange, since many other worlds compile fine from Public SVN. We'll look into it. Thanks for the report and research.

Re: Error compiling 1418

Posted: Sun Aug 23, 2015 9:55 am
by Xinux
It's a issue with vs2013 and winsock i had the same issue when i tried vs2013 i ended up just going back to vs2012.

Re: Error compiling 1418

Posted: Sun Aug 23, 2015 10:09 am
by zippyzee
Or do the define that it asks for and all is good. I believe that's what I did.

Re: Error compiling 1418

Posted: Sun Aug 23, 2015 12:12 pm
by jimm0thy
Thanks guys, figured it was something simple I was missing. Installed VS2012 and it compiled fine