Compare commits

3 Commits

Author SHA1 Message Date
0ab470367c fix: fix safe num overflow ops issue under MSVC 2025-08-13 09:51:40 +08:00
c4d441f5fa fix: fix pycodec MSVC error 2025-08-13 09:36:21 +08:00
f8a696b4e8 fix: fix MSVC __VA_OPT__ error 2025-08-13 09:24:19 +08:00
6 changed files with 27 additions and 10 deletions

View File

@ -113,6 +113,9 @@ target_compile_options(YYCCommonplace
PUBLIC
# Order build as UTF-8 in MSVC
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
# Order preprocessor conformance mode (fix __VA_OPT__ error in MSVC)
$<$<CXX_COMPILER_ID:MSVC>:/Zc:preprocessor>
)
# Fix GCC std::stacktrace link error

View File

@ -393,6 +393,15 @@ namespace yycc::carton::pycodec {
#endif
}
// YYC MARK:
// Define a macro for following class ctor
// We only need initialize member if we are in Iconv environment.
#if defined(YYCC_PYCODEC_WIN32_BACKEND)
#define CTOR_INITLIST_TYPE1
#else
#define CTOR_INITLIST_TYPE1 : inner()
#endif
#pragma endregion
#pragma region Char -> UTF8
@ -447,7 +456,7 @@ namespace yycc::carton::pycodec {
#pragma region WChar -> UTF8
WcharToUtf8::WcharToUtf8() : inner() {}
WcharToUtf8::WcharToUtf8() CTOR_INITLIST_TYPE1 {}
WcharToUtf8::~WcharToUtf8() {}
@ -463,7 +472,7 @@ namespace yycc::carton::pycodec {
#pragma region UTF8 -> WChar
Utf8ToWchar::Utf8ToWchar() : inner() {}
Utf8ToWchar::Utf8ToWchar() CTOR_INITLIST_TYPE1 {}
Utf8ToWchar::~Utf8ToWchar() {}
@ -479,7 +488,7 @@ namespace yycc::carton::pycodec {
#pragma region UTF8 -> UTF16
Utf8ToUtf16::Utf8ToUtf16() : inner() {}
Utf8ToUtf16::Utf8ToUtf16() CTOR_INITLIST_TYPE1 {}
Utf8ToUtf16::~Utf8ToUtf16() {}
@ -495,7 +504,7 @@ namespace yycc::carton::pycodec {
#pragma region UTF16 -> UTF8
Utf16ToUtf8::Utf16ToUtf8() : inner() {}
Utf16ToUtf8::Utf16ToUtf8() CTOR_INITLIST_TYPE1 {}
Utf16ToUtf8::~Utf16ToUtf8() {}
@ -511,7 +520,7 @@ namespace yycc::carton::pycodec {
#pragma region UTF8 -> UTF32
Utf8ToUtf32::Utf8ToUtf32() : inner() {}
Utf8ToUtf32::Utf8ToUtf32() CTOR_INITLIST_TYPE1 {}
Utf8ToUtf32::~Utf8ToUtf32() {}
@ -527,7 +536,7 @@ namespace yycc::carton::pycodec {
#pragma region UTF32 -> UTF8
Utf32ToUtf8::Utf32ToUtf8() : inner() {}
Utf32ToUtf8::Utf32ToUtf8() CTOR_INITLIST_TYPE1 {}
Utf32ToUtf8::~Utf32ToUtf8() {}

View File

@ -17,6 +17,11 @@
// Import essential header if we are using Windows function family.
#if defined(YYCC_HARDWARE_OVERFLOW_WIN32_FNS)
// YYC MARK:
// This macro is crucial for including "intsafe.h"
// Without this, "intsafe.h" will not enable signed integral operations.
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
#include "../windows/import_guard_head.hpp"
#include <intsafe.h>
#include "../windows/import_guard_tail.hpp"

View File

@ -34,7 +34,7 @@ namespace yycc::rust::panic {
* The macro parameters are the message to format and its arguments, following \c std::format syntax.
* This macro essentially calls \c std::format internally.
*/
#define RS_PANICF(msg, ...) RS_PANIC(std::format(msg __VA_OPT__(, ) __VA_ARGS__))
#define RS_PANICF(msg, ...) RS_PANIC(std::format(msg __VA_OPT__(,) __VA_ARGS__))
/**
* @brief Immediately crashes the entire program like Rust's \c panic! macro.

View File

@ -14,7 +14,7 @@ namespace yycctest::num::parse {
#define TEST_SUCCESS(type_t, expected_value, string_value, ...) \
{ \
std::u8string cache_string(string_value); \
auto rv = PARSE::parse<type_t>(cache_string __VA_OPT__(, ) __VA_ARGS__); \
auto rv = PARSE::parse<type_t>(cache_string __VA_OPT__(,) __VA_ARGS__); \
ASSERT_TRUE(rv.has_value()); \
EXPECT_EQ(rv.value(), expected_value); \
}
@ -22,7 +22,7 @@ namespace yycctest::num::parse {
#define TEST_FAIL(type_t, string_value, ...) \
{ \
std::u8string cache_string(string_value); \
auto rv = PARSE::parse<type_t>(cache_string __VA_OPT__(, ) __VA_ARGS__); \
auto rv = PARSE::parse<type_t>(cache_string __VA_OPT__(,) __VA_ARGS__); \
EXPECT_FALSE(rv.has_value()); \
}

View File

@ -11,7 +11,7 @@ namespace yycctest::num::stringify {
#define TEST_SUCCESS(type_t, value, string_value, ...) \
{ \
type_t cache = value; \
std::u8string ret = STRINGIFY::stringify<type_t>(cache __VA_OPT__(, ) __VA_ARGS__); \
std::u8string ret = STRINGIFY::stringify<type_t>(cache __VA_OPT__(,) __VA_ARGS__); \
EXPECT_EQ(ret, string_value); \
}