Cast and print std::chrono:nanoseconds::count() as intmax_t because its
actual type might be larger than the 64 bytes expected by %PRId64.
The problem was not, technically, specific to clang or FreeBSD.
The error message says "long" because %PRId64 is %ld on platforms where
"long" is 64 bits:
format specifies type 'long' but the argument has type [...]
'long long' [-Wformat]
static void
dump_time_nanoseconds(StoreEntry *entry, const char *name, const std::chrono::nanoseconds &var)
{
- storeAppendPrintf(entry, "%s %" PRId64 " nanoseconds\n", name, var.count());
+ // std::chrono::nanoseconds::rep is unknown a priori so we cast to (and print) the largest supported integer
+ storeAppendPrintf(entry, "%s %jd nanoseconds\n", name, static_cast<intmax_t>(var.count()));
}
static void