From 1fd132f0c989758511332ac950b86d9f90f43fd2 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Wed, 19 Jun 2024 13:28:51 +0800 Subject: [PATCH] fix: fix build error in Linux environment. - fix various build error in Linux environment. - the convertion between UTF8, UTF16 and UTF32 have error in Linux and will be fixed in future. --- src/ConsoleHelper.cpp | 16 ++++++++++------ src/EncodingHelper.cpp | 1 + testbench/main.cpp | 14 +++++++------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/ConsoleHelper.cpp b/src/ConsoleHelper.cpp index 550856e..5b998e5 100644 --- a/src/ConsoleHelper.cpp +++ b/src/ConsoleHelper.cpp @@ -171,7 +171,7 @@ namespace YYCC::ConsoleHelper { #else // just return true and do nothing - return true + return true; #endif } @@ -226,7 +226,7 @@ namespace YYCC::ConsoleHelper { WinConsoleWrite(strl, bIsErr); #else // in linux, directly use C function to write. - std::fputs(strl.c_str(), to_stderr ? stderr : stdout); + std::fputs(strl.c_str(), bIsErr ? stderr : stdout); #endif } @@ -245,11 +245,13 @@ namespace YYCC::ConsoleHelper { } void Write(const char* u8_strl) { - RawWrite(u8_strl, va_list()); + va_list empty; + RawWrite(u8_strl, empty); } void WriteLine(const char* u8_strl) { - RawWrite(u8_strl, va_list()); + va_list empty; + RawWrite(u8_strl, empty); } void ErrFormat(const char* u8_fmt, ...) { @@ -267,11 +269,13 @@ namespace YYCC::ConsoleHelper { } void ErrWrite(const char* u8_strl) { - RawWrite(u8_strl, va_list()); + va_list empty; + RawWrite(u8_strl, empty); } void ErrWriteLine(const char* u8_strl) { - RawWrite(u8_strl, va_list()); + va_list empty; + RawWrite(u8_strl, empty); } } diff --git a/src/EncodingHelper.cpp b/src/EncodingHelper.cpp index a0126d1..47733df 100644 --- a/src/EncodingHelper.cpp +++ b/src/EncodingHelper.cpp @@ -1,6 +1,7 @@ #include "EncodingHelper.hpp" #include +#include namespace YYCC::EncodingHelper { diff --git a/testbench/main.cpp b/testbench/main.cpp index a2f7cf9..9c15b13 100644 --- a/testbench/main.cpp +++ b/testbench/main.cpp @@ -23,7 +23,7 @@ namespace YYCCTestbench { #define TEST_UNICODE_STR_EMOJI "\U0001F363 \u2716 \U0001F37A" // sushi x beer mug #define CONCAT(prefix, strl) prefix ## strl -#define CPP_U8_LITERAL(strl) strl +#define CPP_U8_LITERAL(strl) reinterpret_cast(CONCAT(u8, strl)) #define CPP_U16_LITERAL(strl) CONCAT(u, strl) #define CPP_U32_LITERAL(strl) CONCAT(U, strl) #define CPP_WSTR_LITERAL(strl) CONCAT(L, strl) @@ -394,10 +394,10 @@ namespace YYCCTestbench { int main(int argc, char** args) { //YYCCTestbench::ConsoleTestbench(); YYCCTestbench::EncodingTestbench(); - //YYCCTestbench::StringTestbench(); - //YYCCTestbench::ParserTestbench(); - //YYCCTestbench::DialogTestbench(); - //YYCCTestbench::ExceptionTestbench(); - //YYCCTestbench::WinFctTestbench(); - //YYCCTestbench::FsPathPatch(); + YYCCTestbench::StringTestbench(); + YYCCTestbench::ParserTestbench(); + YYCCTestbench::DialogTestbench(); + YYCCTestbench::ExceptionTestbench(); + YYCCTestbench::WinFctTestbench(); + YYCCTestbench::FsPathPatch(); }