Common/Utilities: ported StringConvert helpers from 335 branch

This commit is contained in:
Treeston authored and Ovahlord committed 2025-07-26 00:40:54 +02:00
1 parent c22ba4438e
commit faef256861
3 files changed
+309

No files matched your search

+25
View File
@@ -13,6 +13,31 @@ else()
message(STATUS "Clang: Minimum version required is ${CLANG_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
endif()
# This tests for a bug in clang-7 that causes linkage to fail for 64-bit from_chars (in some configurations)
# If the clang requirement is bumped to >= clang-8, you can remove this check, as well as
# the associated ifdef block in src/common/Utilities/StringConvert.h
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <charconv>
#include <cstdint>
int main()
{
uint64_t n;
char const c[] = \"0\";
std::from_chars(c, c+1, n);
return static_cast<int>(n);
}
" CLANG_HAVE_PROPER_CHARCONV)
if (NOT CLANG_HAVE_PROPER_CHARCONV)
message(STATUS "Clang: Detected from_chars bug for 64-bit integers, workaround enabled")
target_compile_definitions(trinity-compile-option-interface
INTERFACE
TRINITY_NEED_CHARCONV_WORKAROUND)
endif()
if(WITH_WARNINGS)
target_compile_options(trinity-warning-interface
INTERFACE