Skip to content

Commit fb79b50

Browse files
HaroldoCopilot
andcommitted
CoinTime: replace C++17 inline variable with C++11 static local
coinWallclockStart was declared as an inline variable (C++17), causing build failures on MSVC when compiled without /std:c++17: CoinTime.hpp(94): error C7525: inline variables require at least '/std:c++17' Replace with a static local variable inside CoinWallclockTime(), which is guaranteed to be initialised exactly once and thread-safely under C++11, without requiring any build-system changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ce084a4 commit fb79b50

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/CoinTime.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,13 @@ inline double CoinGetTimeOfDay()
8888

8989
#endif // _MSC_VER
9090

91-
/// Wall-clock epoch seconds at static-initialisation time (before main()).
92-
/// Defined as an inline variable (C++17) so every translation unit shares
93-
/// the same object and the value is fixed exactly once.
94-
inline const double coinWallclockStart = CoinGetTimeOfDay();
95-
96-
/// Returns elapsed wall-clock time in seconds since program start.
91+
/// Returns elapsed wall-clock time in seconds since the first call.
92+
/// Uses a static local variable (C++11) so the start time is captured
93+
/// exactly once, thread-safely, without requiring C++17 inline variables.
9794
inline double CoinWallclockTime()
9895
{
99-
return CoinGetTimeOfDay() - coinWallclockStart;
96+
static const double wallclockStart = CoinGetTimeOfDay();
97+
return CoinGetTimeOfDay() - wallclockStart;
10098
}
10199

102100
//#############################################################################

0 commit comments

Comments
 (0)