From f0667be8b5c10020c64a6bac088f75861d1bbbba Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 1 Apr 2022 07:16:56 -0700 Subject: [PATCH] vulkan/util: Make STACK_ARRAY() C++-friendly C++ doesn't like the {0} initializer pattern when the first field is not an integer, let's use the {} when __cplusplus is defined. Reviewed-by: Jason Ekstrand Part-of: --- src/vulkan/util/vk_util.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vulkan/util/vk_util.h b/src/vulkan/util/vk_util.h index 019ab5bf793..7a33e77def3 100644 --- a/src/vulkan/util/vk_util.h +++ b/src/vulkan/util/vk_util.h @@ -278,8 +278,14 @@ vk_spec_info_to_nir_spirv(const VkSpecializationInfo *spec_info, #define STACK_ARRAY_SIZE 8 +#ifdef __cplusplus +#define STACK_ARRAY_ZERO_INIT {} +#else +#define STACK_ARRAY_ZERO_INIT {0} +#endif + #define STACK_ARRAY(type, name, size) \ - type _stack_##name[STACK_ARRAY_SIZE] = {0}; \ + type _stack_##name[STACK_ARRAY_SIZE] = STACK_ARRAY_ZERO_INIT; \ type *const name = \ ((size) <= STACK_ARRAY_SIZE ? _stack_##name : (type *)malloc((size) * sizeof(type)))