Skip to content

Commit

Permalink
Fix for NK_OFFSETOF on Emscripten (#663)
Browse files Browse the repository at this point in the history
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);
```
  • Loading branch information
RobLoach authored Jul 29, 2024
1 parent 2795d90 commit be0a3f6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit be0a3f6

Please sign in to comment.