From 13d3efb2d1c450810df969a6892cd51e160115db Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Sat, 2 Sep 2023 21:19:56 -0700 Subject: [PATCH] compiler/types: Add workaround to use builtin_type_macros.h in C In most versions of C, bool is defined as _Bool, so the macro for bool gets generated with the wrong name. Reviewed-by: Emma Anholt Part-of: --- src/compiler/builtin_type_macros.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/compiler/builtin_type_macros.h b/src/compiler/builtin_type_macros.h index 114f095..9ff1bd7 100644 --- a/src/compiler/builtin_type_macros.h +++ b/src/compiler/builtin_type_macros.h @@ -46,7 +46,22 @@ DECL_SIMPLE_TYPE(void, GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0) DECL_SIMPLE_TYPE(vtype ## 8, 0, btype, 8, 1) \ DECL_SIMPLE_TYPE(vtype ## 16, 0, btype, 16, 1) +#ifndef __cplusplus +#if defined(bool) +#define BOOL_NEEDS_REDEFINITION_WORKAROUND +#undef bool +#endif +#endif + DECL_VEC_TYPE(bool, bvec, GLSL_TYPE_BOOL, GL_BOOL) + +#ifndef __cplusplus +#if defined(BOOL_NEEDS_REDEFINITION_WORKAROUND) +#undef BOOL_NEEDS_REDEFINITION_WORKAROUND +#define bool _Bool +#endif +#endif + DECL_VEC_TYPE(int, ivec, GLSL_TYPE_INT, GL_INT) DECL_VEC_TYPE(uint, uvec, GLSL_TYPE_UINT, GL_UNSIGNED_INT) DECL_VEC_TYPE(float, vec, GLSL_TYPE_FLOAT, GL_FLOAT) -- 2.7.4