From a844a943b5c89fc7c1bef550bd24cd5109649fa7 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 28 Oct 2025 20:45:21 +0100 Subject: [PATCH] It seems alignas() is C11 and raylib is C99, so not fully supported #5312 Added a workaround but it has other probably undesired implications --- src/external/rlsw.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/external/rlsw.h b/src/external/rlsw.h index cfb2d236f..6f59bba95 100644 --- a/src/external/rlsw.h +++ b/src/external/rlsw.h @@ -610,11 +610,19 @@ SWAPI void swBindTexture(uint32_t id); #define RLSW_IMPLEMENTATION #if defined(RLSW_IMPLEMENTATION) -#include #include #include #include // Required for: floorf(), fabsf() +#if defined(_MSC_VER) + #define ALIGNAS(x) __declspec(align(x)) +#elif defined(__GNUC__) || defined(__clang__) + #define ALIGNAS(x) __attribute__((aligned(x))) +#else + #include + #define ALIGNAS(x) alignas(x) +#endif + #if defined(__FMA__) && defined(__AVX2__) #define SW_HAS_FMA_AVX2 #include @@ -687,8 +695,8 @@ SWAPI void swBindTexture(uint32_t id); #define SW_DEG2RAD (SW_PI/180.0f) #define SW_RAD2DEG (180.0f/SW_PI) -#define SW_COLOR_PIXEL_SIZE (SW_COLOR_BUFFER_BITS/8) -#define SW_DEPTH_PIXEL_SIZE (SW_DEPTH_BUFFER_BITS/8) +#define SW_COLOR_PIXEL_SIZE 4 //(SW_COLOR_BUFFER_BITS >> 3) +#define SW_DEPTH_PIXEL_SIZE (SW_DEPTH_BUFFER_BITS >> 3) #if (SW_COLOR_BUFFER_BITS == 8) #define SW_COLOR_TYPE uint8_t @@ -817,14 +825,15 @@ typedef struct { float ty; // Texel height } sw_texture_t; -typedef struct { - alignas(SW_COLOR_PIXEL_SIZE) +// Pixel data type +// WARNING: ALIGNAS() macro requires a constant value (not operand) +typedef ALIGNAS(SW_COLOR_PIXEL_SIZE) struct { SW_COLOR_TYPE color[SW_COLOR_PACK_COMP]; SW_DEPTH_TYPE depth[SW_DEPTH_PACK_COMP]; } sw_pixel_t; typedef struct { - sw_pixel_t* pixels; + sw_pixel_t *pixels; int width; int height; int allocSz;