From 00efa17975ddbe4ca72a4522df08432297b8ebcf Mon Sep 17 00:00:00 2001 From: "kinly.lei" Date: Tue, 2 Jul 2024 10:05:06 +0800 Subject: [PATCH 1/2] fixed: 1. cmake add msvc option /utf-8 2. xml_parsing using filesystem u8path at c++17 --- CMakeLists.txt | 2 ++ src/xml_parsing.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38d820bb2..2b6445045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,8 @@ else() include(cmake/conan_build.cmake) endif() +add_compile_options("$<$:/utf-8>") +add_compile_options("$<$:/utf-8>") ############################################################# # LIBRARY diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index adb8c8247..deaf7beec 100644 --- a/src/xml_parsing.cpp +++ b/src/xml_parsing.cpp @@ -19,11 +19,17 @@ #include #include +#define __bt_cplusplus __cplusplus +#if defined(_MSVC_LANG) && !defined(__clang__) +#define __bt_cplusplus (_MSC_VER == 1900 ? 201103L : _MSVC_LANG) +#endif + #if defined(__linux) || defined(__linux__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wattributes" #endif + #include #include "behaviortree_cpp/xml_parsing.h" #include "tinyxml2/tinyxml2.h" @@ -37,6 +43,8 @@ #include #endif +#include + #include "behaviortree_cpp/blackboard.h" #include "behaviortree_cpp/tree_node.h" #include "behaviortree_cpp/utils/demangle_util.h" @@ -254,7 +262,12 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes) break; } - std::filesystem::path file_path(incl_node->Attribute("path")); +#if __xx_cplusplus >= 202002L + auto file_path(incl_node->Attribute("path")); +#else + auto file_path(std::filesystem::u8path(incl_node->Attribute("path"))); +#endif + const char* ros_pkg_relative_path = incl_node->Attribute("ros_pkg"); if(ros_pkg_relative_path) From 1a3ccd2764cf9d16f92fbe5edbc4efa4ce776a0d Mon Sep 17 00:00:00 2001 From: "kinly.lei" Date: Tue, 2 Jul 2024 10:15:01 +0800 Subject: [PATCH 2/2] fixed define using error --- src/xml_parsing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index deaf7beec..9bcfac08d 100644 --- a/src/xml_parsing.cpp +++ b/src/xml_parsing.cpp @@ -262,7 +262,7 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes) break; } -#if __xx_cplusplus >= 202002L +#if __bt_cplusplus >= 202002L auto file_path(incl_node->Attribute("path")); #else auto file_path(std::filesystem::u8path(incl_node->Attribute("path")));