From c826bbd6f023e878057f22457ea3caf72de60bd4 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 4 Jan 2018 14:01:34 +0100 Subject: [PATCH] Fix several compilation warnings. --- src/lol/sys/threadtypes.h | 8 ++++---- src/lol/sys/timer.h | 6 +++--- src/math/real.cpp | 17 +++++++++-------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/lol/sys/threadtypes.h b/src/lol/sys/threadtypes.h index 427d174a..bdafbe5c 100644 --- a/src/lol/sys/threadtypes.h +++ b/src/lol/sys/threadtypes.h @@ -97,7 +97,7 @@ protected: class BaseThreadManager : public Entity { public: - char const *GetName() { return ""; } + std::string GetName() const { return ""; } BaseThreadManager(int thread_max); BaseThreadManager(int thread_max, int thread_min); virtual ~BaseThreadManager(); @@ -163,7 +163,7 @@ private: class DefaultThreadManager : public BaseThreadManager { public: - char const *GetName() { return ""; } + std::string GetName() const { return ""; } DefaultThreadManager(int thread_max) : BaseThreadManager(thread_max, thread_max) { } @@ -222,7 +222,7 @@ public: } }; public: - char const *GetName() { return ""; } + std::string GetName() const { return ""; } FileUpdateTester(uint32_t frame_skip = 4) : BaseThreadManager(1) { m_frame_skip = frame_skip; } @@ -252,7 +252,7 @@ typedef FileUpdateTester::Status FileUpdateStatus; class AsyncImageLoader : public BaseThreadManager { public: - char const *GetName() { return ""; } + std::string GetName() const { return ""; } AsyncImageLoader(int thread_max) : BaseThreadManager(thread_max, 0) { diff --git a/src/lol/sys/timer.h b/src/lol/sys/timer.h index e30f932e..ed96452c 100644 --- a/src/lol/sys/timer.h +++ b/src/lol/sys/timer.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2016 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // © 2016 Guillaume Bittoun // // Lol Engine is free software. It comes without any warranty, to @@ -45,11 +45,11 @@ public: private: std::chrono::steady_clock::time_point m_tp; - float get_seconds(bool reset) + float get_seconds(bool do_reset) { auto tp = std::chrono::steady_clock::now(), tp0 = m_tp; - if (reset) + if (do_reset) m_tp = tp; return std::chrono::duration_cast>(tp - tp0).count(); diff --git a/src/math/real.cpp b/src/math/real.cpp index fe05916f..f3cf31fc 100644 --- a/src/math/real.cpp +++ b/src/math/real.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2017 Sam Hocevar +// Copyright © 2010—2018 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -22,7 +22,11 @@ namespace lol /* * First handle explicit specialisation of our templates. - * + */ + +template<> int real::DEFAULT_BIGIT_COUNT = 16; + +/* * Initialisation order is not important because everything is * done on demand, but here is the dependency list anyway: * - fast_log() requires R_1 @@ -89,9 +93,6 @@ LOL_CONSTANT_GETTER(R_SQRT1_2, R_SQRT2() / 2); * Now carry on with the rest of the Real class. */ -template<> -int real::DEFAULT_BIGIT_COUNT = 16; - template<> real::Real() : m_exponent(0), m_sign(false), @@ -116,7 +117,7 @@ template<> real::Real(uint64_t i) if (i) { /* Only works with 32-bit bigits for now */ - static_assert(sizeof(bigit_t) == 4); + static_assert(sizeof(bigit_t) == 4, "bigit_t must be 32-bit"); int delta = 1; while ((i >> 63) == 0) @@ -155,7 +156,7 @@ template<> real::Real(double d) break; default: /* Only works with 32-bit bigits for now */ - static_assert(sizeof(bigit_t) == 4); + static_assert(sizeof(bigit_t) == 4, "bigit_t must be 32-bit"); m_exponent = exponent - ((1 << 10) - 1); m_mantissa.resize(DEFAULT_BIGIT_COUNT); m_mantissa[0] = (bigit_t)(u.x >> 20); @@ -271,7 +272,7 @@ template<> real::Real(char const *str) finished = true; break; } - LOL_ATTR_FALLTHROUGH /* FIXME: why doesn’t this seem to work? */ + LOL_ATTR_FALLTHROUGH; case 'a': case 'b': case 'c': case 'd': case 'f': case 'A': case 'B': case 'C': case 'D': case 'F': case '0': case '1': case '2': case '3': case '4':