diff --git a/src/Corrade/Utility/Memory.h b/src/Corrade/Utility/Memory.h index 08e9faa44..93ae9ccc4 100644 --- a/src/Corrade/Utility/Memory.h +++ b/src/Corrade/Utility/Memory.h @@ -40,7 +40,11 @@ #include "Corrade/Utility/visibility.h" #ifdef CORRADE_TARGET_UNIX +#ifdef CORRADE_TARGET_APPLE +#include +#else #include +#endif #elif defined(CORRADE_TARGET_WINDOWS) /* as well, but I don't want to include all the nasty shit */ extern "C" void* __cdecl _aligned_malloc(size_t, size_t); @@ -219,10 +223,12 @@ template Containers::Array allocateAligned(Co which seems weird and confusing. Handle that explicitly instead. */ if(!size) return {}; - /* aligned_alloc() needs _ISOC11_SOURCE, let's hope it just works. If you - get a compilation error here, please complain -- in that case I need to - switch to posix_memalign(). */ - return Containers::Array{static_cast(aligned_alloc(alignment, size*sizeof(T))), size, Implementation::alignedDeleter}; + /* I would use aligned_alloc() but then there's APPLE who comes and says + NO. And on top of everything they DARE to have posix_memalign() in a + different header. */ + void* data{}; + CORRADE_INTERNAL_ASSERT_OUTPUT(posix_memalign(&data, alignment, size*sizeof(T)) == 0); + return Containers::Array{static_cast(data), size, Implementation::alignedDeleter}; /* Windows */ #elif defined(CORRADE_TARGET_WINDOWS)