Don't try to use aligned_alloc on macOS 10.14.x or earlier; it's not available in the OS's libc++ even if the compiler supports it. The developers of mongo-c-driver decline to fix issues exclusively affecting unsupported OS versions so we get to maintain this patch forever. https://jira.mongodb.org/browse/CDRIVER-4609 --- src/libbson/src/bson/bson-memory.c.orig 2024-01-02 14:57:49.000000000 -0600 +++ src/libbson/src/bson/bson-memory.c 2024-01-03 21:30:51.000000000 -0600 @@ -19,6 +19,9 @@ #include #include #include +#ifdef __APPLE__ +#include +#endif #include #include @@ -34,6 +37,7 @@ static void * _aligned_alloc_impl (size_t alignment, size_t num_bytes) #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \ + (!defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) && \ !defined(_WIN32) && !defined(__ANDROID__) && !defined(_AIX) { return aligned_alloc (alignment, num_bytes);