so it does not get substituted by the preprocessor unconditionally.
this change helps to address the compiling failure when using boost
1.79 using MinGW, like:
../build.deps/mingw/boost/include/boost/align/aligned_allocator.hpp: In member function 'void boost::alignment::aligned_allocator<T, Alignment>::deallocate(boost::alignment::aligned_allocator<T, Alignment>::pointer, boost::alignment::aligned_allocator<T, Alignment>::size_type)':
../src/include/compat.h:352:27: error: '_aligned_free' is not a member of 'boost::alignment'; did you mean 'aligned_free'?
352 | #define aligned_free(ptr) _aligned_free(ptr)
| ^~~~~~~~~~~~~
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
#include "acconfig.h"
#include <sys/types.h>
#include <errno.h>
+#include <stdlib.h>
#include <unistd.h>
#if defined(__linux__)
#define compat_closesocket closesocket
// Use "aligned_free" when freeing memory allocated using posix_memalign or
// _aligned_malloc. Using "free" will crash.
-#define aligned_free(ptr) _aligned_free(ptr)
+static inline void aligned_free(void* ptr) {
+ _aligned_free(ptr);
+}
// O_CLOEXEC is not defined on Windows. Since handles aren't inherited
// with subprocesses unless explicitly requested, we'll define this
#define SOCKOPT_VAL_TYPE void*
-#define aligned_free(ptr) free(ptr)
+static inline void aligned_free(void* ptr) {
+ free(ptr);
+}
static inline int compat_closesocket(int fildes) {
return close(fildes);
}