From f8f169dbbc81c19a4521ed2b434c196157ba8780 Mon Sep 17 00:00:00 2001
From: Ben Cumming <bcumming@cscs.ch>
Date: Fri, 11 May 2018 16:43:42 +0200
Subject: [PATCH] Fix small compilation errors on OS X (#482)

* Use `sys/types.h` instead of `endian.h` for greater portability.
* Avoid use of constructor for `std::vector` in unit tests that is only available from C++14.
---
 src/util/debug.hpp         | 4 +++-
 tests/unit/test_padded.cpp | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/util/debug.hpp b/src/util/debug.hpp
index dfc55392..a2d53b51 100644
--- a/src/util/debug.hpp
+++ b/src/util/debug.hpp
@@ -7,7 +7,9 @@
 #include <utility>
 
 extern "C" {
-#include <endian.h>
+// The system header endian.h is not in /sys/include/ on Mac OS X.
+// Include sys/types.h, which pulls in endian.h on all systems.
+#include <sys/types.h>
 }
 
 #include <threading/threading.hpp>
diff --git a/tests/unit/test_padded.cpp b/tests/unit/test_padded.cpp
index ebe2049b..7f2f52b3 100644
--- a/tests/unit/test_padded.cpp
+++ b/tests/unit/test_padded.cpp
@@ -19,7 +19,7 @@ static bool is_aligned(void* p, std::size_t k) {
 
 TEST(padded_vector, alignment) {
     padded_allocator<double> pa(1024);
-    pvector<double> a(101, pa);
+    pvector<double> a(101, 0.0, pa);
 
     EXPECT_EQ(1024u, a.get_allocator().alignment());
     EXPECT_TRUE(is_aligned(a.data(), 1024));
@@ -29,14 +29,14 @@ TEST(padded_vector, allocator_constraints) {
     EXPECT_THROW(padded_allocator<char>(7), std::range_error);
 
     padded_allocator<char> pa(2); // less than sizeof(void*)
-    std::vector<char, padded_allocator<char>> v(7, pa);
+    std::vector<char, padded_allocator<char>> v(7, 'a', pa);
 
     EXPECT_TRUE(is_aligned(v.data(), sizeof(void*)));
 }
 
 TEST(padded_vector, allocator_propagation) {
     padded_allocator<double> pa(1024);
-    pvector<double> a(101, pa);
+    pvector<double> a(101, 0, pa);
 
     EXPECT_EQ(pa, a.get_allocator());
 
-- 
GitLab