From be0a3f6141f596722c9172b4eb66eba32a845a20 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 29 Jul 2024 11:07:32 -0400 Subject: [PATCH] Fix for NK_OFFSETOF on Emscripten (#663) Fixes the following error with Emscripten, where `__builtin_offset` isn't available. This disables the usage of it when on Emscripten. ``` nuklear.h:8978:38: error: defining a type within '__builtin_offsetof' is a C23 extension [-Werror,-Wc23-extensions] 8978 | NK_STORAGE const nk_size align = NK_ALIGNOF(struct nk_command); ``` --- nuklear.h | 2 +- src/nuklear.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuklear.h b/nuklear.h index 8f2b3ef54..12fa7ab12 100644 --- a/nuklear.h +++ b/nuklear.h @@ -5804,7 +5804,7 @@ struct nk_context { #define NK_ALIGN_PTR_BACK(x, mask)\ (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1)))) -#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__) +#if ((defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)) && !defined(EMSCRIPTEN) #define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m)) #else #define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m)) diff --git a/src/nuklear.h b/src/nuklear.h index 43afb1de1..7c627e946 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -5582,7 +5582,7 @@ struct nk_context { #define NK_ALIGN_PTR_BACK(x, mask)\ (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1)))) -#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__) +#if ((defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)) && !defined(EMSCRIPTEN) #define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m)) #else #define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))