It seems alignas() is C11 and raylib is C99, so not fully supported #5312

Added a workaround but it has other probably undesired implications
This commit is contained in:
Ray
2025-10-28 20:45:21 +01:00
parent f106301d46
commit a844a943b5

21
src/external/rlsw.h vendored
View File

@@ -610,11 +610,19 @@ SWAPI void swBindTexture(uint32_t id);
#define RLSW_IMPLEMENTATION #define RLSW_IMPLEMENTATION
#if defined(RLSW_IMPLEMENTATION) #if defined(RLSW_IMPLEMENTATION)
#include <stdalign.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
#include <math.h> // Required for: floorf(), fabsf() #include <math.h> // 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 <stdalign.h>
#define ALIGNAS(x) alignas(x)
#endif
#if defined(__FMA__) && defined(__AVX2__) #if defined(__FMA__) && defined(__AVX2__)
#define SW_HAS_FMA_AVX2 #define SW_HAS_FMA_AVX2
#include <immintrin.h> #include <immintrin.h>
@@ -687,8 +695,8 @@ SWAPI void swBindTexture(uint32_t id);
#define SW_DEG2RAD (SW_PI/180.0f) #define SW_DEG2RAD (SW_PI/180.0f)
#define SW_RAD2DEG (180.0f/SW_PI) #define SW_RAD2DEG (180.0f/SW_PI)
#define SW_COLOR_PIXEL_SIZE (SW_COLOR_BUFFER_BITS/8) #define SW_COLOR_PIXEL_SIZE 4 //(SW_COLOR_BUFFER_BITS >> 3)
#define SW_DEPTH_PIXEL_SIZE (SW_DEPTH_BUFFER_BITS/8) #define SW_DEPTH_PIXEL_SIZE (SW_DEPTH_BUFFER_BITS >> 3)
#if (SW_COLOR_BUFFER_BITS == 8) #if (SW_COLOR_BUFFER_BITS == 8)
#define SW_COLOR_TYPE uint8_t #define SW_COLOR_TYPE uint8_t
@@ -817,14 +825,15 @@ typedef struct {
float ty; // Texel height float ty; // Texel height
} sw_texture_t; } sw_texture_t;
typedef struct { // Pixel data type
alignas(SW_COLOR_PIXEL_SIZE) // 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_COLOR_TYPE color[SW_COLOR_PACK_COMP];
SW_DEPTH_TYPE depth[SW_DEPTH_PACK_COMP]; SW_DEPTH_TYPE depth[SW_DEPTH_PACK_COMP];
} sw_pixel_t; } sw_pixel_t;
typedef struct { typedef struct {
sw_pixel_t* pixels; sw_pixel_t *pixels;
int width; int width;
int height; int height;
int allocSz; int allocSz;