From 266fddbffac622c71c178c64dae3fef17fe151ee Mon Sep 17 00:00:00 2001 From: FinnHornhoover Date: Tue, 8 Sep 2020 03:40:16 +0300 Subject: [PATCH 1/2] fixed warnings and compile errors for msys2 --- Makefile | 2 +- src/CNStructs.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d76932a..786cc55 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ PROTOCOL_VERSION?=104 WIN_CC=x86_64-w64-mingw32-gcc WIN_CXX=x86_64-w64-mingw32-g++ WIN_CFLAGS=-O3 #-g3 -fsanitize=address -WIN_CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O3 -fno-tree-dce -fno-inline-small-functions -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) #-g3 -fsanitize=address +WIN_CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O3 -fno-tree-dce -fno-tree-fre -fno-tree-vrp -fno-ipa-sra -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) #-g3 -fsanitize=address WIN_LDFLAGS=-static -lws2_32 -lwsock32 #-g3 -fsanitize=address WIN_SERVER=bin/winfusion.exe diff --git a/src/CNStructs.cpp b/src/CNStructs.cpp index 2c4c7b5..6d889ea 100644 --- a/src/CNStructs.cpp +++ b/src/CNStructs.cpp @@ -5,16 +5,16 @@ std::string U16toU8(char16_t* src) { try { - std::wstring_convert,char16_t> convert; - return convert.to_bytes(src); - } catch(std::exception e) { + std::wstring_convert,char16_t> convert; + return convert.to_bytes(src); + } catch(const std::exception& e) { return ""; } } // returns number of char16_t that was written at des size_t U8toU16(std::string src, char16_t* des) { - std::wstring_convert,char16_t> convert; + std::wstring_convert,char16_t> convert; std::u16string tmp = convert.from_bytes(src); // copy utf16 string to buffer From 91f512d7403e351bf44866137b8681642f1910bb Mon Sep 17 00:00:00 2001 From: FinnHornhoover Date: Sat, 12 Sep 2020 22:27:03 +0300 Subject: [PATCH 2/2] added version checking for GCC --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 786cc55..cf9d4c3 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,9 @@ PROTOCOL_VERSION?=104 WIN_CC=x86_64-w64-mingw32-gcc WIN_CXX=x86_64-w64-mingw32-g++ WIN_CFLAGS=-O3 #-g3 -fsanitize=address -WIN_CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O3 -fno-tree-dce -fno-tree-fre -fno-tree-vrp -fno-ipa-sra -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) #-g3 -fsanitize=address +WIN_CXX_VANILLA_MINGW_OPT_DISABLES=-fno-tree-dce -fno-inline-small-functions +WIN_CXX_OPT_DISABLES=-fno-tree-dce -fno-tree-fre -fno-tree-vrp -fno-ipa-sra +WIN_CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O3 $(WIN_CXX_OPT_DISABLES) -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) #-g3 -fsanitize=address WIN_LDFLAGS=-static -lws2_32 -lwsock32 #-g3 -fsanitize=address WIN_SERVER=bin/winfusion.exe @@ -98,6 +100,10 @@ windows : CFLAGS=$(WIN_CFLAGS) windows : CXXFLAGS=$(WIN_CXXFLAGS) windows : LDFLAGS=$(WIN_LDFLAGS) windows : SERVER=$(WIN_SERVER) +windows : +ifneq ($(shell $(WIN_CXX) --version | head -1 | egrep -o [0-9]+ | tail -3 | head -1), 10) +WIN_CXX_OPT_DISABLES=$(WIN_CXX_VANILLA_MINGW_OPT_DISABLES) +endif .SUFFIX: .o .c .cpp .h .hpp