diff --git a/CMakeLists.txt b/CMakeLists.txt index e5557b83a..eb5fe579b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,12 +5,8 @@ project(reminecraftpe) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") -if (WIN32 OR LINUX) -set(CMAKE_CXX_STANDARD 11) -else() -set(CMAKE_CXX_STANDARD 98) -endif() -set(CXX_EXTENSIONS OFF) +set(CMAKE_C_STANDARD 99) +set(CMAKE_CXX_EXTENSIONS OFF) # Warnings add_compile_options(-Wall) @@ -47,6 +43,10 @@ if(REMCPE_WIN32) -static-libgcc -static-libstdc++ ) + # Modern MinGW doesn't support C++98 and will error if you try to use it + set(CMAKE_CXX_STANDARD 11) +else() + set(CMAKE_CXX_STANDARD 98) endif() # HaikuOS Network Library diff --git a/compat/vsnprintf.c b/compat/vsnprintf.c new file mode 100644 index 000000000..4a23fe0a9 --- /dev/null +++ b/compat/vsnprintf.c @@ -0,0 +1,6 @@ +#include + +int remcpe_vsnprintf(char *buf, size_t size, const char *format, va_list ap) +{ + return vsnprintf(buf, size, format, ap); +} diff --git a/compat/vsnprintf.h b/compat/vsnprintf.h new file mode 100644 index 000000000..beb46c615 --- /dev/null +++ b/compat/vsnprintf.h @@ -0,0 +1,10 @@ +#pragma once + +#include +#ifndef vsnprintf +#include +extern "C" { +extern int remcpe_vsnprintf(char *, size_t, const char *, va_list ap); +} +#define vsnprintf remcpe_vsnprintf +#endif diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index 83956a711..526d2fbc4 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -1292,6 +1292,8 @@ 84FFBF002ACA3416005A8CCF /* VariadicSQLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD83F2AC810630006A435 /* VariadicSQLParser.cpp */; }; 84FFBF012ACA3416005A8CCF /* VitaIncludes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8412AC810630006A435 /* VitaIncludes.cpp */; }; 84FFBF022ACA3416005A8CCF /* WSAStartupSingleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8442AC810630006A435 /* WSAStartupSingleton.cpp */; }; + 9D36D2F72F0B3C160031ADFD /* vsnprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = 9D36D2F62F0B3C160031ADFD /* vsnprintf.c */; }; + 9D36D2F92F0B3C1F0031ADFD /* vsnprintf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D36D2F82F0B3C1F0031ADFD /* vsnprintf.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -2764,6 +2766,8 @@ 84F77A6C2EA1C27B0045C907 /* LocalPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalPlayer.cpp; sourceTree = ""; }; 84F77A6D2EA1C27B0045C907 /* LocalPlayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LocalPlayer.hpp; sourceTree = ""; }; 84FFBD7E2ACA2876005A8CCF /* libRakNet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRakNet.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 9D36D2F62F0B3C160031ADFD /* vsnprintf.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = vsnprintf.c; sourceTree = ""; }; + 9D36D2F82F0B3C1F0031ADFD /* vsnprintf.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vsnprintf.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -2896,6 +2900,8 @@ 84C0D8022B15A1D0007E1E76 /* PlatformDefinitions.h */, 840DD57A2AC810620006A435 /* SDLKeyCodes.h */, 8466BD092E774DCD00DDDFC4 /* EndianDefinitions.h */, + 9D36D2F62F0B3C160031ADFD /* vsnprintf.c */, + 9D36D2F82F0B3C1F0031ADFD /* vsnprintf.h */, ); name = compat; path = ../../../../compat; @@ -5401,6 +5407,7 @@ 8406FD392AF1823700B09C1D /* Timer.hpp in Headers */, 84EB0E132EE2D4D4008FB007 /* Singleton.hpp in Headers */, 84CCBC402E6183F300E251AF /* DataIO.hpp in Headers */, + 9D36D2F92F0B3C1F0031ADFD /* vsnprintf.h in Headers */, 8406FD3A2AF1823700B09C1D /* Util.hpp in Headers */, 8406FD3B2AF1823700B09C1D /* Utils.hpp in Headers */, 84E001B92AF3A3CB009B9555 /* SmoothFloat.hpp in Headers */, @@ -6441,6 +6448,7 @@ files = ( 84EB0E122EE2D4D4008FB007 /* Singleton.cpp in Sources */, 84E4BFB52AE9869A0023E16A /* CThread.cpp in Sources */, + 9D36D2F72F0B3C160031ADFD /* vsnprintf.c in Sources */, 84CCBC3F2E6183F300E251AF /* DataIO.cpp in Sources */, 84EB0E102EE2D4D4008FB007 /* JsonParser.cpp in Sources */, 84E4BFB62AE9869A0023E16A /* Logger.cpp in Sources */, diff --git a/platforms/windows/projects/Common/Common.vcxproj b/platforms/windows/projects/Common/Common.vcxproj index 4023c1325..f48ee8913 100644 --- a/platforms/windows/projects/Common/Common.vcxproj +++ b/platforms/windows/projects/Common/Common.vcxproj @@ -73,6 +73,7 @@ + @@ -97,6 +98,7 @@ + @@ -109,4 +111,4 @@ - \ No newline at end of file + diff --git a/platforms/windows/projects/Common/Common.vcxproj.filters b/platforms/windows/projects/Common/Common.vcxproj.filters index 24a1b96da..a983cc0e6 100644 --- a/platforms/windows/projects/Common/Common.vcxproj.filters +++ b/platforms/windows/projects/Common/Common.vcxproj.filters @@ -23,6 +23,9 @@ + + Source Files + Source Files @@ -91,6 +94,9 @@ Header Files + + Header Files + Header Files @@ -116,4 +122,4 @@ Header Files\Utility - \ No newline at end of file + diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 927050fa6..463945a7e 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -3,6 +3,7 @@ project(reminecraftpe-core) # Build add_library(reminecraftpe-core STATIC + ../compat/vsnprintf.c common/CThread.cpp common/DataIO.cpp common/Logger.cpp diff --git a/source/common/Util.cpp b/source/common/Util.cpp index a2cc6593f..56c97f1d8 100644 --- a/source/common/Util.cpp +++ b/source/common/Util.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include "Util.hpp" +#include "compat/vsnprintf.h" const std::string Util::EMPTY_STRING = "";