From b2167087ac9d97a6ee024d7ecfc5e29a5bc157f3 Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Wed, 12 Jun 2019 18:15:47 -0400 Subject: Enable compiling on GCC < 5 (#2149) _ISOC11_SOURCE is the preprocessor flag that specifies whether or not aligned_alloc is defined and exists. While GCC versions lower than 5 do include C++11 and C++14 constructs, they do not include std::aligned_alloc, so this check allows compiling on those versions of GCC by defaulting down to posix_memalign in those situations appropriately. --- src/support/alloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/support/alloc.h') diff --git a/src/support/alloc.h b/src/support/alloc.h index d85cbb0f7..fb5815588 100644 --- a/src/support/alloc.h +++ b/src/support/alloc.h @@ -38,7 +38,7 @@ inline void* aligned_malloc(size_t align, size_t size) { if (errno == ENOMEM) ret = nullptr; return ret; -#elif defined(__APPLE__) +#elif defined(__APPLE__) || !defined(_ISOC11_SOURCE) void* ptr; int result = posix_memalign(&ptr, align, size); return result == 0 ? ptr : nullptr; -- cgit v1.2.3