From acd95c325afaf09976400d86733d26b83f28542f Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Mon, 24 Jul 2017 15:36:02 +0300 Subject: [core] Fix issues with the std:: namespace and old compilers Specifically when building Android with GCC 4.9 (which Qt still does :-/) --- include/mbgl/util/string.hpp | 25 +++++++++++++++++++++++++ src/mbgl/annotation/shape_annotation_impl.hpp | 1 + src/mbgl/style/parser.cpp | 1 + src/mbgl/style/sources/geojson_source_impl.cpp | 7 +++++-- src/mbgl/text/shaping.cpp | 3 ++- src/mbgl/tile/geojson_tile.cpp | 1 + src/mbgl/util/dtoa.cpp | 2 ++ src/mbgl/util/http_header.cpp | 2 ++ 8 files changed, 39 insertions(+), 3 deletions(-) diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp index de061647b5..82d317c620 100644 --- a/include/mbgl/util/string.hpp +++ b/include/mbgl/util/string.hpp @@ -1,9 +1,34 @@ #pragma once +#include #include #include +#include #include +// Polyfill needed by Qt when building for Android with GCC +#if defined(__ANDROID__) && defined(__GLIBCXX__) + +namespace std { + +template +std::string to_string(T value) +{ + std::ostringstream oss; + oss << value; + + return oss.str(); +} + +inline int stoi(const std::string &str) +{ + return atoi(str.c_str()); +} + +} // namespace std + +#endif + namespace mbgl { namespace util { diff --git a/src/mbgl/annotation/shape_annotation_impl.hpp b/src/mbgl/annotation/shape_annotation_impl.hpp index ed9e8d015a..caf2cff1a5 100644 --- a/src/mbgl/annotation/shape_annotation_impl.hpp +++ b/src/mbgl/annotation/shape_annotation_impl.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp index 467b44632c..a83897dbf5 100644 --- a/src/mbgl/style/parser.cpp +++ b/src/mbgl/style/parser.cpp @@ -8,6 +8,7 @@ #include #include +#include #include diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index be347af2ab..efa4018b46 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -1,10 +1,13 @@ #include #include #include +#include #include #include +#include + namespace mbgl { namespace style { @@ -52,14 +55,14 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) mapbox::supercluster::Options clusterOptions; clusterOptions.maxZoom = options.clusterMaxZoom; clusterOptions.extent = util::EXTENT; - clusterOptions.radius = std::round(scale * options.clusterRadius); + clusterOptions.radius = ::round(scale * options.clusterRadius); data = std::make_unique( geoJSON.get>(), clusterOptions); } else { mapbox::geojsonvt::Options vtOptions; vtOptions.maxZoom = options.maxzoom; vtOptions.extent = util::EXTENT; - vtOptions.buffer = std::round(scale * options.buffer); + vtOptions.buffer = ::round(scale * options.buffer); vtOptions.tolerance = scale * options.tolerance; data = std::make_unique(geoJSON, vtOptions); } diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index c81f25d4eb..6c7ecff42a 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -7,6 +7,7 @@ #include #include +#include namespace mbgl { @@ -72,7 +73,7 @@ float determineAverageLineWidth(const std::u16string& logicalInput, } } - int32_t targetLineCount = std::fmax(1, std::ceil(totalWidth / maxWidth)); + int32_t targetLineCount = ::fmax(1, std::ceil(totalWidth / maxWidth)); return totalWidth / targetLineCount; } diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp index d5e2e14e54..f6861140b7 100644 --- a/src/mbgl/tile/geojson_tile.cpp +++ b/src/mbgl/tile/geojson_tile.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/src/mbgl/util/dtoa.cpp b/src/mbgl/util/dtoa.cpp index 6ca3e19c3d..0e3aef6117 100644 --- a/src/mbgl/util/dtoa.cpp +++ b/src/mbgl/util/dtoa.cpp @@ -6,6 +6,8 @@ #include #endif +#include + namespace mbgl { namespace util { diff --git a/src/mbgl/util/http_header.cpp b/src/mbgl/util/http_header.cpp index 40711232ff..ce31a06c5e 100644 --- a/src/mbgl/util/http_header.cpp +++ b/src/mbgl/util/http_header.cpp @@ -1,5 +1,7 @@ #include +#include + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" #pragma GCC diagnostic ignored "-Wunused-parameter" -- cgit v1.2.1