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 <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15698>
This commit is contained in:
Boris Brezillon 2022-04-01 07:16:56 -07:00 committed by Marge Bot
parent 8d30204ca4
commit f0667be8b5

View file

@ -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)))