diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index 76a98e8d..9a4d567a 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -238,7 +238,12 @@ inline double hsSwapEndianDouble(double dvalue) * StrPrintf(buffer, arrsize(buffer), "%u", value); * ***/ -#define arrsize(a) (sizeof(a) / sizeof((a)[0])) +#ifdef HAVE_CONSTEXPR + template + constexpr size_t arrsize(_T(&)[_Sz]) { return _Sz; } +#else +# define arrsize(a) (sizeof(a) / sizeof((a)[0])) +#endif /**************************************************************************** diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp index ce0a9027..e3b4338e 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp @@ -102,7 +102,9 @@ static void LookupProcess (Lookup * lookup, unsigned error) { in_addr const * const * const inAddr = (in_addr **) host.h_addr_list; // allocate a buffer large enough to hold all the addresses - size_t count = arrsize(inAddr); + size_t count = 0; + while (inAddr[count]) + ++count; plNetAddress* addrs = new plNetAddress[count]; // fill in address data diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index d16634e7..d5d7447f 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -561,20 +561,6 @@ static void INetAuthFileListRequestCallback ( msg->Send(); } -//============================================================================ -static void INetCliAuthFileRequestCallback ( - ENetError result, - void * param, - const wchar_t filename[], - hsStream * writer -) { - plNetCommFileDownloadMsg * msg = new plNetCommFileDownloadMsg; - msg->result = result; - msg->writer = writer; - StrCopy(msg->filename, filename, arrsize(filename)); - msg->Send(); -} - //============================================================================ static void INetCliGameJoinAgeRequestCallback ( ENetError result, diff --git a/cmake/CompilerChecks.cmake b/cmake/CompilerChecks.cmake index 973b671c..11be0d74 100644 --- a/cmake/CompilerChecks.cmake +++ b/cmake/CompilerChecks.cmake @@ -58,6 +58,11 @@ try_compile(HAVE_GCC_DEPRECATED_ATTR ${PROJECT_BINARY_DIR} COMPILE_DEFINITIONS -DTRY_GCC_ATTR OUTPUT_VARIABLE OUTPUT) +# Look for C++11 constexpr support +try_compile(HAVE_CONSTEXPR ${PROJECT_BINARY_DIR} + ${PROJECT_SOURCE_DIR}/cmake/check_constexpr.cpp + OUTPUT_VARIABLE OUTPUT) + configure_file(${PROJECT_SOURCE_DIR}/cmake/hsCompilerSpecific.h.cmake ${PROJECT_BINARY_DIR}/hsCompilerSpecific.h) include_directories(${PROJECT_BINARY_DIR}) diff --git a/cmake/check_constexpr.cpp b/cmake/check_constexpr.cpp new file mode 100644 index 00000000..bff6467e --- /dev/null +++ b/cmake/check_constexpr.cpp @@ -0,0 +1,6 @@ +constexpr int foo() { return 5; } + +int main(int, char **) +{ + return foo(); +} diff --git a/cmake/hsCompilerSpecific.h.cmake b/cmake/hsCompilerSpecific.h.cmake index 02b8e5d1..242c4cf1 100644 --- a/cmake/hsCompilerSpecific.h.cmake +++ b/cmake/hsCompilerSpecific.h.cmake @@ -51,4 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #cmakedefine HAVE_CXX14_DEPRECATED_ATTR #cmakedefine HAVE_GCC_DEPRECATED_ATTR +#cmakedefine HAVE_CONSTEXPR + #endif