From ec04e858ef6cf584f599918dc25eefc100023cab Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 9 May 2023 17:32:31 +0200 Subject: [PATCH] Fix compilation issues on non-Windows platforms --- Source/ThirdParty/fmt/core.h | 13 ++++++++++++- Source/ThirdParty/fmt/format-inl.h | 8 ++------ Source/ThirdParty/fmt/format.h | 11 ++++++++++- Source/ThirdParty/tracy/client/TracyProfiler.cpp | 4 +++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Source/ThirdParty/fmt/core.h b/Source/ThirdParty/fmt/core.h index 822b802eb..a8b208508 100644 --- a/Source/ThirdParty/fmt/core.h +++ b/Source/ThirdParty/fmt/core.h @@ -8,7 +8,18 @@ #ifndef FMT_CORE_H_ #define FMT_CORE_H_ -// Custom configuration for Flax +/* +Customizations done to fmt lib: +- Expose fmt within Flax DLL +- Use Flax utilities instead of std (eg. string length util, assert) +- Remove: dynamic args, chrono, colors, printf, ranges, os +- Remove file-related api +- Reduce `std` library usage (including `std::string`) +- Disable literal-based api +- Disable compile-time formatting +- Move `bigint`, `format_float` to internal api +- Remove `fmt::ptr`, `fmt::vformat_to_n`, `fmt::print`, `fmt::underlying`, `fmt::to_string`, `fmt::join` +*/ #include "Engine/Platform/Platform.h" #include "Engine/Platform/StringUtils.h" #include "Engine/Core/Templates.h" diff --git a/Source/ThirdParty/fmt/format-inl.h b/Source/ThirdParty/fmt/format-inl.h index 5d5969820..66f14d4e4 100644 --- a/Source/ThirdParty/fmt/format-inl.h +++ b/Source/ThirdParty/fmt/format-inl.h @@ -68,10 +68,6 @@ template FMT_FUNC Char decimal_point_impl(locale_ref) { #endif } // namespace detail -#if !FMT_MSC_VERSION -FMT_API FMT_FUNC format_error::~format_error() noexcept = default; -#endif - namespace detail { template inline bool operator==(basic_fp x, basic_fp y) { @@ -1760,7 +1756,7 @@ int format_float(Float value, int precision, float_specs specs, buffer& bu // This is based on log10(value) == log2(value) / log2(10) and approximation // of log2(value) by e + num_fraction_bits idea from double-conversion. exp = static_cast( - std::ceil((f.e + count_digits<1>(f.f) - 1) * inv_log2_10 - 1e-10)); + ::ceil((f.e + count_digits<1>(f.f) - 1) * inv_log2_10 - 1e-10)); dragon_flags = dragon::fixup; } else if (!is_constant_evaluated() && precision < 0) { // Use Dragonbox for the shortest format. @@ -1858,7 +1854,7 @@ template <> struct formatter { FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) { for_each_codepoint(s, [this](uint32_t cp, string_view) { - if (cp == invalid_code_point) FMT_THROW(std::runtime_error("invalid utf8")); + if (cp == invalid_code_point) FMT_THROW("invalid utf8"); if (cp <= 0xFFFF) { buffer_.push_back(static_cast(cp)); } else { diff --git a/Source/ThirdParty/fmt/format.h b/Source/ThirdParty/fmt/format.h index 1dd983af5..0550af1b5 100644 --- a/Source/ThirdParty/fmt/format.h +++ b/Source/ThirdParty/fmt/format.h @@ -1546,6 +1546,7 @@ FMT_CONSTEXPR inline fp get_cached_power(int min_exponent, } #ifndef _MSC_VER +#include # define FMT_SNPRINTF snprintf #else FMT_API auto fmt_snprintf(char* buf, size_t size, const char* fmt, ...) -> int; @@ -1749,6 +1750,8 @@ inline auto find_escape(const char* begin, const char* end) \endrst */ #define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string, ) +#else +#define FMT_STRING(s) s #endif template @@ -3333,7 +3336,13 @@ template struct formatter> : formatter { specs_.precision, specs_.precision_ref, ctx); return detail::write_int_localized( ctx.out(), static_cast>(t.value), 0, specs_, - detail::digit_grouping({"\3", ','})); + detail::digit_grouping( +#if FMT_USE_LOCALE_GROUPING + {"\3", ','} +#else + {','} +#endif + )); } }; diff --git a/Source/ThirdParty/tracy/client/TracyProfiler.cpp b/Source/ThirdParty/tracy/client/TracyProfiler.cpp index 46a9d36e4..cba3593da 100644 --- a/Source/ThirdParty/tracy/client/TracyProfiler.cpp +++ b/Source/ThirdParty/tracy/client/TracyProfiler.cpp @@ -369,8 +369,10 @@ static int64_t SetupHwTimer() #endif } #endif +#else +static int64_t SetupHwTimer() +{ #endif - return Profiler::GetTime(); } #else