Skip to content

Add a patch in rviz_ogre_vendor to build with clang on macOS #1510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: rolling
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions rviz_ogre_vendor/patches/0006-macos-char-traits-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
--- a/Components/Overlay/include/OgreUTFString.h
+++ b/Components/Overlay/include/OgreUTFString.h
@@ -32,6 +32,100 @@
#include <string>
#include <stdexcept>

+#if (OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS) && __clang_major__ >= 15
+#include <string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string is already included

+namespace std {
+ template<>
+ struct char_traits<unsigned short>
+ {
+ using char_type = unsigned short;
+ using int_type = unsigned int;
+ using off_type = streamoff;
+ using pos_type = streampos;
+ using state_type = mbstate_t;
+
+ static void assign(char_type& r, const char_type& a) { r = a; }
+ static bool eq(const char_type& a, const char_type& b) { return a == b; }
+ static bool lt(const char_type& a, const char_type& b) { return a < b; }
+
+ static int compare(const char_type* s1, const char_type* s2, size_t n) {
+ for (size_t i = 0; i < n; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include <cstddef>

+ if (lt(s1[i], s2[i])) return -1;
+ if (lt(s2[i], s1[i])) return 1;
+ }
+ return 0;
+ }
+
+ static size_t length(const char_type* s) {
+ size_t i = 0;
+ while (!eq(s[i], char_type())) ++i;
+ return i;
+ }
+
+ static const char_type* find(const char_type* s, size_t n, const char_type& a) {
+ for (size_t i = 0; i < n; ++i) {
+ if (eq(s[i], a)) return s + i;
+ }
+ return nullptr;
+ }
+
+ static char_type* move(char_type* s1, const char_type* s2, size_t n) {
+ return static_cast<char_type*>(memmove(s1, s2, n * sizeof(char_type)));
+ }
+
+ static char_type* copy(char_type* s1, const char_type* s2, size_t n) {
+ return static_cast<char_type*>(memcpy(s1, s2, n * sizeof(char_type)));
+ }
+
+ static char_type* assign(char_type* s, size_t n, char_type a) {
+ for (size_t i = 0; i < n; ++i) {
+ assign(s[i], a);
+ }
+ return s;
+ }
+
+ static int_type not_eof(const int_type& c) {
+ return !eq_int_type(c, eof()) ? c : 0;
+ }
+
+ static char_type to_char_type(const int_type& c) { return static_cast<char_type>(c); }
+ static int_type to_int_type(const char_type& c) { return static_cast<int_type>(c); }
+ static bool eq_int_type(const int_type& c1, const int_type& c2) { return c1 == c2; }
+ static int_type eof() { return static_cast<int_type>(-1); }
+ };
+}
+#endif
+
+#if (OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS) && __clang_major__ >= 15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the #if is the same as the upper one. Is this duplicated ?

+#include <string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include already included

+namespace std {
+ template<>
+ struct char_traits<unsigned int>
+ {
+ using char_type = unsigned int;
+ using int_type = unsigned int;
+ using off_type = streamoff;
+ using pos_type = streampos;
+ using state_type = mbstate_t;
+
+ static void assign(char_type& r, const char_type& a) { r = a; }
+ static bool eq(const char_type& a, const char_type& b) { return a == b; }
+ static bool lt(const char_type& a, const char_type& b) { return a < b; }
+
+ static int compare(const char_type* s1, const char_type* s2, size_t n) {
+ for (size_t i = 0; i < n; ++i) {
+ if (lt(s1[i], s2[i])) return -1;
+ if (lt(s2[i], s1[i])) return 1;
+ }
+ return 0;
+ }
+
+ static size_t length(const char_type* s) {
+ size_t i = 0;
+ while (!eq(s[i], char_type())) ++i;
+ return i;
+ }
+
+ static const char_type* find(const char_type* s, size_t n, const char_type& a) {
+ for (size_t i = 0; i < n; ++i) {
+ if (eq(s[i], a)) return s + i;
+ }
+ return nullptr;
+ }
+
+ static char_type* move(char_type* s1, const char_type* s2, size_t n) {
+ return static_cast<char_type*>(memmove(s1, s2, n * sizeof(char_type)));
+ }
+
+ static char_type* copy(char_type* s1, const char_type* s2, size_t n) {
+ return static_cast<char_type*>(memcpy(s1, s2, n * sizeof(char_type)));
+ }
+
+ static char_type* assign(char_type* s, size_t n, char_type a) {
+ for (size_t i = 0; i < n; ++i) {
+ assign(s[i], a);
+ }
+ return s;
+ }
+
+ static int_type not_eof(const int_type& c) {
+ return !eq_int_type(c, eof()) ? c : 0;
+ }
+
+ static char_type to_char_type(const int_type& c) { return static_cast<char_type>(c); }
+ static int_type to_int_type(const char_type& c) { return static_cast<int_type>(c); }
+ static bool eq_int_type(const int_type& c1, const int_type& c2) { return c1 == c2; }
+ static int_type eof() { return static_cast<int_type>(-1); }
+ };
+}
+#endif
+
// Workaround for VC7/7.1/8.0/9.0 (2003 - 2008):
// when build with /MD or /MDd, VC have both std::basic_string<unsigned short> and
// basic_string<__wchar_t> instantiated in msvcprt[d].lib/MSVCP71[D].dll, but the header