Fix compile error in Codeblocks.

The compile error might be caused by different typedef of PVOID.
This commit is contained in:
Kirigaya Kazuto 2018-12-12 02:31:27 +08:00
parent 8b58c30b07
commit 2a740e924c
2 changed files with 17 additions and 4 deletions

View File

@ -7,6 +7,11 @@
#include "gsock.h"
// C++ version check
#if __cplusplus<201103L
#error "GSock requires at least C++11 to compile."
#endif
#ifdef GSOCK_DEBUG
#pragma message("GSock Debug mode compiled in")
#include <cstdio>
@ -1355,7 +1360,8 @@ static int convertback_ipv46(const sockaddr* paddr, std::string& _out_IPStr)
char buff[128] = { 0 };
if (paddr->sa_family == AF_INET)
{
if (inet_ntop(AF_INET, &(((const sockaddr_in*)paddr)->sin_addr), buff, 128)!=NULL)
// Change to non-const pointer to avoid compile error in Codeblocks.
if (inet_ntop(AF_INET, (void*)&(((const sockaddr_in*)paddr)->sin_addr), buff, 128)!=NULL)
{
_out_IPStr = std::move(std::string(buff));
return 0;
@ -1364,7 +1370,8 @@ static int convertback_ipv46(const sockaddr* paddr, std::string& _out_IPStr)
}
else if (paddr->sa_family == AF_INET6)
{
if (inet_ntop(AF_INET6, &(((const sockaddr_in6*)paddr)->sin6_addr), buff, 128) != NULL)
// Change to non-const pointer to avoid compile error in Codeblocks.
if (inet_ntop(AF_INET6, (void*)&(((const sockaddr_in6*)paddr)->sin6_addr), buff, 128) != NULL)
{
_out_IPStr = std::move(std::string(buff));
return 1;

View File

@ -6,9 +6,15 @@
#include "gsock_helper.h"
#include <cstring>
// C++ version check
#if __cplusplus<201103L
#error "GSock requires at least C++11 to compile."
#endif
#ifdef _WIN32
/// Using Win8.1
#define _WIN32_WINNT 0x0603
// See gsock.cpp for more information on _WIN32_WINNT.
// Using Win10 by default.
#define _WIN32_WINNT 0x0A00
#include <winsock2.h>
#include <ws2tcpip.h>
#ifdef _MSC_VER