Skip to content

Instantly share code, notes, and snippets.

@pgriess
Last active December 25, 2015 21:48
Show Gist options
  • Save pgriess/7044785 to your computer and use it in GitHub Desktop.
Save pgriess/7044785 to your computer and use it in GitHub Desktop.
Patch for glog-0.3.3 to build against libc++.
diff -ur glog-0.3.3-PRISTINE/src/glog/stl_logging.h.in glog-0.3.3/src/glog/stl_logging.h.in
--- glog-0.3.3-PRISTINE/src/glog/stl_logging.h.in 2013-01-09 07:57:36.000000000 -0600
+++ glog-0.3.3/src/glog/stl_logging.h.in 2013-10-18 12:15:28.000000000 -0500
@@ -53,7 +53,9 @@
#ifdef __GNUC__
# include <ext/hash_set>
# include <ext/hash_map>
-# include <ext/slist>
+#ifdef __GLIBCXX__
+# include <ext/slist>
+#endif
#endif
// Forward declare these two, and define them after all the container streams
@@ -80,7 +82,7 @@
OUTPUT_TWO_ARG_CONTAINER(std::vector)
OUTPUT_TWO_ARG_CONTAINER(std::deque)
OUTPUT_TWO_ARG_CONTAINER(std::list)
-#ifdef __GNUC__
+#ifdef __GLIBCXX__
OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
#endif
diff -ur glog-0.3.3-PRISTINE/src/stl_logging_unittest.cc glog-0.3.3/src/stl_logging_unittest.cc
--- glog-0.3.3-PRISTINE/src/stl_logging_unittest.cc 2013-01-09 07:59:57.000000000 -0600
+++ glog-0.3.3/src/stl_logging_unittest.cc 2013-10-18 12:11:25.000000000 -0500
@@ -65,7 +65,7 @@
v.push_back(30);
ostringstream ss;
ss << v;
- EXPECT_EQ(ss.str(), "10 20 30");
+ EXPECT_STREQ(ss.str().c_str(), "10 20 30");
vector<int> copied_v(v);
CHECK_EQ(v, copied_v); // This must compile.
}
@@ -92,7 +92,13 @@
hs.insert(30);
ostringstream ss;
ss << hs;
- EXPECT_EQ(ss.str(), "10 20 30");
+#if defined(__GLIBCXX__)
+ EXPECT_STREQ(ss.str().c_str(), "10 20 30");
+#elif defined(_LIBCPP_VERSION)
+ EXPECT_STREQ(ss.str().c_str(), "30 20 10");
+#else
+#error Unknown C++ standard library.
+#endif
hash_set<int> copied_hs(hs);
CHECK_EQ(hs, copied_hs); // This must compile.
}
@@ -107,7 +113,13 @@
hm[30] = "thirty";
ostringstream ss;
ss << hm;
+#if defined(__GLIBCXX__)
EXPECT_EQ(ss.str(), "(10, ten) (20, twenty) (30, thirty)");
+#elif defined(_LIBCPP_VERSION)
+ EXPECT_EQ(ss.str(), "(30, thirty) (20, twenty) (10, ten)");
+#else
+#error Unknown C++ standard library.
+#endif
hash_map<int, string> copied_hm(hm);
CHECK_EQ(hm, copied_hm); // this must compile
}
@@ -155,7 +167,13 @@
hs.insert(30);
ostringstream ss;
ss << hs;
- EXPECT_EQ(ss.str(), "10 20 30");
+#if defined(__GLIBCXX__)
+ EXPECT_STREQ(ss.str().c_str(), "10 20 30");
+#elif defined(_LIBCPP_VERSION)
+ EXPECT_STREQ(ss.str().c_str(), "30 20 10");
+#else
+#error Unknown C++ standard library.
+#endif
hash_set<int, user_hash> copied_hs(hs);
CHECK_EQ(hs, copied_hs); // This must compile.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment