Fix compilation issues on non-Windows platforms

This commit is contained in:
Wojtek Figat
2023-05-09 17:32:31 +02:00
parent 421db7fee2
commit ec04e858ef
4 changed files with 27 additions and 9 deletions

View File

@@ -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"

View File

@@ -68,10 +68,6 @@ template <typename Char> 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 <typename F> inline bool operator==(basic_fp<F> x, basic_fp<F> y) {
@@ -1760,7 +1756,7 @@ int format_float(Float value, int precision, float_specs specs, buffer<char>& 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<int>(
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<detail::bigint> {
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<wchar_t>(cp));
} else {

View File

@@ -1546,6 +1546,7 @@ FMT_CONSTEXPR inline fp get_cached_power(int min_exponent,
}
#ifndef _MSC_VER
#include <stdio.h>
# 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 <size_t width, typename Char, typename OutputIt>
@@ -3333,7 +3336,13 @@ template <typename T> struct formatter<group_digits_view<T>> : formatter<T> {
specs_.precision, specs_.precision_ref, ctx);
return detail::write_int_localized(
ctx.out(), static_cast<detail::uint64_or_128_t<T>>(t.value), 0, specs_,
detail::digit_grouping<char>({"\3", ','}));
detail::digit_grouping<char>(
#if FMT_USE_LOCALE_GROUPING
{"\3", ','}
#else
{','}
#endif
));
}
};

View File

@@ -369,8 +369,10 @@ static int64_t SetupHwTimer()
#endif
}
#endif
#else
static int64_t SetupHwTimer()
{
#endif
return Profiler::GetTime();
}
#else