From 058de296284f99d4b44ee1b7bde0c31ed50cab33 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Wed, 29 Jun 2016 01:20:59 +0200 Subject: [PATCH] Implement std::to_string for Android (#231) --- rclcpp/include/rclcpp/utilities.hpp | 16 ++++++++++++++++ rclcpp/src/rclcpp/executor.cpp | 1 + rclcpp/src/rclcpp/parameter.cpp | 5 +++-- rclcpp/src/rclcpp/utilities.cpp | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/rclcpp/include/rclcpp/utilities.hpp b/rclcpp/include/rclcpp/utilities.hpp index 1bed7ac..4dc797d 100644 --- a/rclcpp/include/rclcpp/utilities.hpp +++ b/rclcpp/include/rclcpp/utilities.hpp @@ -26,6 +26,22 @@ #include "rmw/macros.h" #include "rmw/rmw.h" +#ifdef ANDROID +#include +#include + +namespace std +{ +template +std::string to_string(T value) +{ + std::ostringstream os; + os << value; + return os.str(); +} +} +#endif + namespace rclcpp { namespace utilities diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index b02e4a6..cee7a64 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -21,6 +21,7 @@ #include "rclcpp/executor.hpp" #include "rclcpp/scope_exit.hpp" +#include "rclcpp/utilities.hpp" #include "rcl_interfaces/msg/intra_process_message.hpp" diff --git a/rclcpp/src/rclcpp/parameter.cpp b/rclcpp/src/rclcpp/parameter.cpp index a7473e5..8ee929a 100644 --- a/rclcpp/src/rclcpp/parameter.cpp +++ b/rclcpp/src/rclcpp/parameter.cpp @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "rclcpp/parameter.hpp" - #include #include #include #include +#include "rclcpp/parameter.hpp" +#include "rclcpp/utilities.hpp" + using rclcpp::parameter::ParameterType; using rclcpp::parameter::ParameterVariant; diff --git a/rclcpp/src/rclcpp/utilities.cpp b/rclcpp/src/rclcpp/utilities.cpp index 73297ee..9a96538 100644 --- a/rclcpp/src/rclcpp/utilities.cpp +++ b/rclcpp/src/rclcpp/utilities.cpp @@ -126,7 +126,7 @@ rclcpp::utilities::init(int argc, char * argv[]) // NOLINTNEXTLINE(runtime/arrays) char error_string[error_length]; #ifndef _WIN32 -#ifdef _GNU_SOURCE +#if (defined(_GNU_SOURCE) && !defined(ANDROID)) char * msg = strerror_r(errno, error_string, error_length); if (msg != error_string) { strncpy(error_string, msg, error_length);