From db0f9b481acb49f15d0f48087c81760a8c86f395 Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Wed, 7 Sep 2022 16:21:34 +0200 Subject: [PATCH] Changed implementation of vma_aligned_alloc to only use aligned_alloc when C++17 is enabled, where the function is defined. See #285 May break on some platforms! If it affects you, please enable C++17 or later in your compiler or provide custom implementation of macro VMA_SYSTEM_ALIGNED_MALLOC (and VMA_SYSTEM_ALIGNED_FREE if needed) using the API of your system. --- include/vk_mem_alloc.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index d090864..6a2223e 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -2745,11 +2745,17 @@ static void* vma_aligned_alloc(size_t alignment, size_t size) { return _aligned_malloc(size, alignment); } -#else +#elif __cplusplus >= 201703L // Compiler conforms to C++17. static void* vma_aligned_alloc(size_t alignment, size_t size) { return aligned_alloc(alignment, size); } +#else +static void* vma_aligned_alloc(size_t alignment, size_t size) +{ + VMA_ASSERT(0 && "Could not implement aligned_alloc automatically. Please enable C++17 or later in your compiler or provide custom implementation of macro VMA_SYSTEM_ALIGNED_MALLOC (and VMA_SYSTEM_ALIGNED_FREE if needed) using the API of your system."); + return VMA_NULL; +} #endif #if defined(_WIN32)