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

View File

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