Skip to content

Commit fb25dee

Browse files
committed
Fix warnings in C89 builds
1 parent 6322f53 commit fb25dee

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

nuklear.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9216,6 +9216,7 @@ NK_API void
92169216
nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
92179217
const struct nk_nine_slice *slc, struct nk_color col)
92189218
{
9219+
struct nk_image img;
92199220
const struct nk_image *slcimg = (const struct nk_image*)slc;
92209221
nk_ushort rgnX, rgnY, rgnW, rgnH;
92219222
rgnX = slcimg->region[0];
@@ -9224,8 +9225,14 @@ nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
92249225
rgnH = slcimg->region[3];
92259226

92269227
/* top-left */
9227-
struct nk_image img = {slcimg->handle, slcimg->w, slcimg->h,
9228-
{rgnX, rgnY, slc->l, slc->t}};
9228+
img.handle = slcimg->handle;
9229+
img.w = slcimg->w;
9230+
img.h = slcimg->h;
9231+
img.region[0] = rgnX;
9232+
img.region[1] = rgnY;
9233+
img.region[2] = slc->l;
9234+
img.region[3] = slc->t;
9235+
92299236
nk_draw_image(b,
92309237
nk_rect(r.x, r.y, (float)slc->l, (float)slc->t),
92319238
&img, col);
@@ -23483,8 +23490,8 @@ NK_API struct nk_nine_slice
2348323490
nk_sub9slice_ptr(void *ptr, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
2348423491
{
2348523492
struct nk_nine_slice s;
23486-
nk_zero(&s, sizeof(s));
2348723493
struct nk_image *i = &s.img;
23494+
nk_zero(&s, sizeof(s));
2348823495
i->handle.ptr = ptr;
2348923496
i->w = w; i->h = h;
2349023497
i->region[0] = (nk_ushort)rgn.x;
@@ -23498,8 +23505,8 @@ NK_API struct nk_nine_slice
2349823505
nk_sub9slice_id(int id, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
2349923506
{
2350023507
struct nk_nine_slice s;
23501-
nk_zero(&s, sizeof(s));
2350223508
struct nk_image *i = &s.img;
23509+
nk_zero(&s, sizeof(s));
2350323510
i->handle.id = id;
2350423511
i->w = w; i->h = h;
2350523512
i->region[0] = (nk_ushort)rgn.x;
@@ -23513,8 +23520,8 @@ NK_API struct nk_nine_slice
2351323520
nk_sub9slice_handle(nk_handle handle, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
2351423521
{
2351523522
struct nk_nine_slice s;
23516-
nk_zero(&s, sizeof(s));
2351723523
struct nk_image *i = &s.img;
23524+
nk_zero(&s, sizeof(s));
2351823525
i->handle = handle;
2351923526
i->w = w; i->h = h;
2352023527
i->region[0] = (nk_ushort)rgn.x;
@@ -23528,8 +23535,8 @@ NK_API struct nk_nine_slice
2352823535
nk_nine_slice_handle(nk_handle handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
2352923536
{
2353023537
struct nk_nine_slice s;
23531-
nk_zero(&s, sizeof(s));
2353223538
struct nk_image *i = &s.img;
23539+
nk_zero(&s, sizeof(s));
2353323540
i->handle = handle;
2353423541
i->w = 0; i->h = 0;
2353523542
i->region[0] = 0;
@@ -23543,8 +23550,8 @@ NK_API struct nk_nine_slice
2354323550
nk_nine_slice_ptr(void *ptr, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
2354423551
{
2354523552
struct nk_nine_slice s;
23546-
nk_zero(&s, sizeof(s));
2354723553
struct nk_image *i = &s.img;
23554+
nk_zero(&s, sizeof(s));
2354823555
NK_ASSERT(ptr);
2354923556
i->handle.ptr = ptr;
2355023557
i->w = 0; i->h = 0;
@@ -23559,8 +23566,8 @@ NK_API struct nk_nine_slice
2355923566
nk_nine_slice_id(int id, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
2356023567
{
2356123568
struct nk_nine_slice s;
23562-
nk_zero(&s, sizeof(s));
2356323569
struct nk_image *i = &s.img;
23570+
nk_zero(&s, sizeof(s));
2356423571
i->handle.id = id;
2356523572
i->w = 0; i->h = 0;
2356623573
i->region[0] = 0;

src/nuklear_9slice.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ NK_API struct nk_nine_slice
1010
nk_sub9slice_ptr(void *ptr, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
1111
{
1212
struct nk_nine_slice s;
13-
nk_zero(&s, sizeof(s));
1413
struct nk_image *i = &s.img;
14+
nk_zero(&s, sizeof(s));
1515
i->handle.ptr = ptr;
1616
i->w = w; i->h = h;
1717
i->region[0] = (nk_ushort)rgn.x;
@@ -25,8 +25,8 @@ NK_API struct nk_nine_slice
2525
nk_sub9slice_id(int id, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
2626
{
2727
struct nk_nine_slice s;
28-
nk_zero(&s, sizeof(s));
2928
struct nk_image *i = &s.img;
29+
nk_zero(&s, sizeof(s));
3030
i->handle.id = id;
3131
i->w = w; i->h = h;
3232
i->region[0] = (nk_ushort)rgn.x;
@@ -40,8 +40,8 @@ NK_API struct nk_nine_slice
4040
nk_sub9slice_handle(nk_handle handle, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
4141
{
4242
struct nk_nine_slice s;
43-
nk_zero(&s, sizeof(s));
4443
struct nk_image *i = &s.img;
44+
nk_zero(&s, sizeof(s));
4545
i->handle = handle;
4646
i->w = w; i->h = h;
4747
i->region[0] = (nk_ushort)rgn.x;
@@ -55,8 +55,8 @@ NK_API struct nk_nine_slice
5555
nk_nine_slice_handle(nk_handle handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
5656
{
5757
struct nk_nine_slice s;
58-
nk_zero(&s, sizeof(s));
5958
struct nk_image *i = &s.img;
59+
nk_zero(&s, sizeof(s));
6060
i->handle = handle;
6161
i->w = 0; i->h = 0;
6262
i->region[0] = 0;
@@ -70,8 +70,8 @@ NK_API struct nk_nine_slice
7070
nk_nine_slice_ptr(void *ptr, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
7171
{
7272
struct nk_nine_slice s;
73-
nk_zero(&s, sizeof(s));
7473
struct nk_image *i = &s.img;
74+
nk_zero(&s, sizeof(s));
7575
NK_ASSERT(ptr);
7676
i->handle.ptr = ptr;
7777
i->w = 0; i->h = 0;
@@ -86,8 +86,8 @@ NK_API struct nk_nine_slice
8686
nk_nine_slice_id(int id, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
8787
{
8888
struct nk_nine_slice s;
89-
nk_zero(&s, sizeof(s));
9089
struct nk_image *i = &s.img;
90+
nk_zero(&s, sizeof(s));
9191
i->handle.id = id;
9292
i->w = 0; i->h = 0;
9393
i->region[0] = 0;

src/nuklear_draw.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ NK_API void
418418
nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
419419
const struct nk_nine_slice *slc, struct nk_color col)
420420
{
421+
struct nk_image img;
421422
const struct nk_image *slcimg = (const struct nk_image*)slc;
422423
nk_ushort rgnX, rgnY, rgnW, rgnH;
423424
rgnX = slcimg->region[0];
@@ -426,8 +427,14 @@ nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
426427
rgnH = slcimg->region[3];
427428

428429
/* top-left */
429-
struct nk_image img = {slcimg->handle, slcimg->w, slcimg->h,
430-
{rgnX, rgnY, slc->l, slc->t}};
430+
img.handle = slcimg->handle;
431+
img.w = slcimg->w;
432+
img.h = slcimg->h;
433+
img.region[0] = rgnX;
434+
img.region[1] = rgnY;
435+
img.region[2] = slc->l;
436+
img.region[3] = slc->t;
437+
431438
nk_draw_image(b,
432439
nk_rect(r.x, r.y, (float)slc->l, (float)slc->t),
433440
&img, col);

0 commit comments

Comments
 (0)