From fc0745a699a0ef60c080e9c2ff5eaecde9cb5306 Mon Sep 17 00:00:00 2001 From: Sudarsana Babu Nagineni Date: Thu, 9 Aug 2018 17:13:05 +0300 Subject: [core] Fix build when building Qt Location plugin for Android - log2 is not available on Android before API 18. - Android doesn't have 'round' on the std:: namespace when using g++. Co-authored-by: Thiago Marcos P. Santos --- include/mbgl/math/log2.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/mbgl') diff --git a/include/mbgl/math/log2.hpp b/include/mbgl/math/log2.hpp index 6a1ba23ed9..3136ac22b4 100644 --- a/include/mbgl/math/log2.hpp +++ b/include/mbgl/math/log2.hpp @@ -2,6 +2,11 @@ #include #include +#include + +#if defined(__ANDROID__) +#include +#endif namespace mbgl { namespace util { @@ -12,3 +17,14 @@ uint32_t ceil_log2(uint64_t x); } // namespace util } // namespace mbgl + +// log2 is not available on Android before API 18. +#if defined(__ANDROID__) && defined(__GNUC__) && \ + defined(__ANDROID_API__) && __ANDROID_API__ < 18 + +template +typename std::enable_if_t::value, T> log2(T x) { + return ::log(x) / M_LN2; +} + +#endif -- cgit v1.2.1