Skip to content

Commit 4d00aba

Browse files
ashvardanianab-10
andcommitted
Fix: Can't std::format(time) on macOS
Co-authored-by: Armin Stepanyan <[email protected]>
1 parent 35824e6 commit 4d00aba

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

less_slow.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6038,7 +6038,7 @@ struct log_printf_t {
60386038
// `std::chrono::high_resolution_clock` is usually just an alias to either `system_clock` or
60396039
// `steady_clock`. There is debate on whether using it is a good idea at all.
60406040
// https://en.cppreference.com/w/cpp/chrono/high_resolution_clock
6041-
#if defined(_MSC_VER)
6041+
#if defined(_MSC_VER) || defined(__APPLE__)
60426042
auto now = std::chrono::system_clock::now();
60436043
#else
60446044
auto now = std::chrono::high_resolution_clock::now();
@@ -6069,7 +6069,10 @@ struct log_printf_t {
60696069

60706070
BENCHMARK(logging<log_printf_t>)->Name("log_printf")->MinTime(2);
60716071

6072-
#if !defined(_MSC_VER)
6072+
/**
6073+
* Formatting `std::chrono` with `std::format` fails on both Windows and MacOS.
6074+
*/
6075+
#if !defined(_MSC_VER) && !defined(__APPLE__)
60736076
#if defined(__cpp_lib_format)
60746077
#include <format> // `std::format_to_n`
60756078

0 commit comments

Comments
 (0)