From 339d339e9dfbffd6f5fd1f7c03281f1f34704a8c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 16 Sep 2024 13:54:14 +0200 Subject: [PATCH] corelib/time: fix (easy) -Wunused-const-variable warnings in _p.h's Make the constexpr variables inline to silence Clang. There's another batch of such warnings for the _data_p.h files, and they are actually pointing to a real problem: If two TUs include these headers, the static constexpr tables actually get duplicated. Created QTBUG-128930 to track the issue. Amends 6d97cf0e573f11ae1fae11441e6fa747c34be21c and fa9244700e016403b162932211023c65f4bb0d6b. Pick-to: 6.7 6.5 Task-number: QTBUG-126219 Change-Id: Idb0cd55e424a870be6127fdf8399d01e9f3e9ac8 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira (cherry picked from commit 5064cb6feff6178cf3c307790ba028514c3d3040) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/time/qcalendarmath_p.h | 6 +++--- src/corelib/time/qdatetime_p.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/corelib/time/qcalendarmath_p.h b/src/corelib/time/qcalendarmath_p.h index c785803ce3d..03153b0eed1 100644 --- a/src/corelib/time/qcalendarmath_p.h +++ b/src/corelib/time/qcalendarmath_p.h @@ -108,10 +108,10 @@ template constexpr Int qMod(Int a) { return qDivMod::num; +inline constexpr qint64 MSECS_PER_SEC = milliseconds::period::den; +inline constexpr qint64 MSECS_PER_MIN = SECS_PER_MIN * MSECS_PER_SEC; +inline constexpr qint64 MSECS_PER_HOUR = SECS_PER_HOUR * MSECS_PER_SEC; +inline constexpr qint64 MSECS_PER_DAY = SECS_PER_DAY * MSECS_PER_SEC; +inline constexpr qint64 JULIAN_DAY_FOR_EPOCH = 2440588; // result of QDate(1970, 1, 1).toJulianDay() +inline constexpr qint64 JulianDayMax = Q_INT64_C( 784354017364); +inline constexpr qint64 JulianDayMin = Q_INT64_C(-784350574879); } }