Skip to content

Commit b216708

Browse files
zeroshadekripken
authored andcommitted
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.
1 parent 284c935 commit b216708

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/support/alloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ inline void* aligned_malloc(size_t align, size_t size) {
3838
if (errno == ENOMEM)
3939
ret = nullptr;
4040
return ret;
41-
#elif defined(__APPLE__)
41+
#elif defined(__APPLE__) || !defined(_ISOC11_SOURCE)
4242
void* ptr;
4343
int result = posix_memalign(&ptr, align, size);
4444
return result == 0 ? ptr : nullptr;

0 commit comments

Comments
 (0)