Skip to content

Commit 455b404

Browse files
committed
Fixed issue Immediate-Mode-UI#87 - Compiler warnings about unused functions
Fixed compiler warning by removing unused function nk_sqrt Fixed compiler warning if you bring your own sin/cos/strtod.... Bump version for breaking nk_sqrt changes Updated changelog
1 parent b939d43 commit 455b404

File tree

10 files changed

+79
-68
lines changed

10 files changed

+79
-68
lines changed

doc/nuklear.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,6 +2312,16 @@
23122312
- [x]: Major version with API and library breaking changes
23132313
- [yy]: Minor version with non-breaking API and library changes
23142314
- [zz]: Bug fix version with no direct changes to API
2315+
- 2020/04/09 (4.02.1) - Removed unused nk_sqrt function to fix compiler warnings
2316+
- Fixed compiler warnings if you bring your own methods for
2317+
nk_cos/nk_sin/nk_strtod/nk_memset/nk_memcopy/nk_dtoa
2318+
- 2020/04/06 (4.01.10) - Fix bug: Do not use pool before checking for NULL
2319+
- 2020/03/22 (4.01.9) - Fix bug where layout state wasn't restored correctly after
2320+
popping a tree.
2321+
- 2020/03/11 (4.01.8) - Fix bug where padding is subtracted from widget
2322+
- 2020/03/06 (4.01.7) - Fix bug where width padding was applied twice
2323+
- 2020/02/06 (4.01.6) - Update stb_truetype.h and stb_rect_pack.h and separate them
2324+
- 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT
23152325
- 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit
23162326
- 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header
23172327
when NK_BUTTON_TRIGGER_ON_RELEASE is defined.

example/extended.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ basic_demo(struct nk_context *ctx, struct media *media)
394394
* IMAGE POPUP
395395
*------------------------------------------------*/
396396
if (image_active) {
397-
struct nk_panel popup;
398397
if (nk_popup_begin(ctx, NK_POPUP_STATIC, "Image Popup", 0, nk_rect(265, 0, 320, 220))) {
399398
nk_layout_row_static(ctx, 82, 82, 3);
400399
for (i = 0; i < 9; ++i) {

nuklear.h

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,7 +3730,10 @@ NK_API int nk_stricmp(const char *s1, const char *s2);
37303730
NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
37313731
NK_API int nk_strtoi(const char *str, const char **endptr);
37323732
NK_API float nk_strtof(const char *str, const char **endptr);
3733+
#ifndef NK_STRTOD
3734+
#define NK_STRTOD nk_strtod
37333735
NK_API double nk_strtod(const char *str, const char **endptr);
3736+
#endif
37343737
NK_API int nk_strfilter(const char *text, const char *regexp);
37353738
NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
37363739
NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score);
@@ -5688,7 +5691,7 @@ template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
56885691
#ifndef STBTT_malloc
56895692
static nk_handle fictional_handle = {0};
56905693

5691-
#define STBTT_malloc(x,u) nk_malloc( fictional_handle, 0, x )
5694+
#define STBTT_malloc(x,u) nk_malloc( fictional_handle, 0, x )
56925695
#define STBTT_free(x,u) nk_mfree( fictional_handle , x)
56935696
#endif
56945697

@@ -5726,28 +5729,6 @@ static nk_handle fictional_handle = {0};
57265729
#define NK_ASSERT(expr) assert(expr)
57275730
#endif
57285731

5729-
#ifndef NK_MEMSET
5730-
#define NK_MEMSET nk_memset
5731-
#endif
5732-
#ifndef NK_MEMCPY
5733-
#define NK_MEMCPY nk_memcopy
5734-
#endif
5735-
#ifndef NK_SQRT
5736-
#define NK_SQRT nk_sqrt
5737-
#endif
5738-
#ifndef NK_SIN
5739-
#define NK_SIN nk_sin
5740-
#endif
5741-
#ifndef NK_COS
5742-
#define NK_COS nk_cos
5743-
#endif
5744-
#ifndef NK_STRTOD
5745-
#define NK_STRTOD nk_strtod
5746-
#endif
5747-
#ifndef NK_DTOA
5748-
#define NK_DTOA nk_dtoa
5749-
#endif
5750-
57515732
#define NK_DEFAULT (-1)
57525733

57535734
#ifndef NK_VSNPRINTF
@@ -5810,9 +5791,12 @@ NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255};
58105791

58115792
/* math */
58125793
NK_LIB float nk_inv_sqrt(float n);
5813-
NK_LIB float nk_sqrt(float x);
5794+
#ifndef NK_SIN
58145795
NK_LIB float nk_sin(float x);
5796+
#endif
5797+
#ifndef NK_COS
58155798
NK_LIB float nk_cos(float x);
5799+
#endif
58165800
NK_LIB nk_uint nk_round_up_pow2(nk_uint v);
58175801
NK_LIB struct nk_rect nk_shrink_rect(struct nk_rect r, float amount);
58185802
NK_LIB struct nk_rect nk_pad_rect(struct nk_rect r, struct nk_vec2 pad);
@@ -5829,12 +5813,19 @@ NK_LIB int nk_is_lower(int c);
58295813
NK_LIB int nk_is_upper(int c);
58305814
NK_LIB int nk_to_upper(int c);
58315815
NK_LIB int nk_to_lower(int c);
5816+
5817+
#ifndef NK_MEMCPY
58325818
NK_LIB void* nk_memcopy(void *dst, const void *src, nk_size n);
5819+
#endif
5820+
#ifndef NK_MEMSET
58335821
NK_LIB void nk_memset(void *ptr, int c0, nk_size size);
5822+
#endif
58345823
NK_LIB void nk_zero(void *ptr, nk_size size);
58355824
NK_LIB char *nk_itoa(char *s, long n);
58365825
NK_LIB int nk_string_float_limit(char *string, int prec);
5826+
#ifndef NK_DTOA
58375827
NK_LIB char *nk_dtoa(char *s, double n);
5828+
#endif
58385829
NK_LIB int nk_text_clamp(const struct nk_user_font *font, const char *text, int text_len, float space, int *glyphs, float *text_width, nk_rune *sep_list, int sep_count);
58395830
NK_LIB struct nk_vec2 nk_text_calculate_text_bounds(const struct nk_user_font *font, const char *begin, int byte_len, float row_height, const char **remaining, struct nk_vec2 *out_offset, int *glyphs, int op);
58405831
#ifdef NK_INCLUDE_STANDARD_VARARGS
@@ -6079,11 +6070,8 @@ nk_inv_sqrt(float n)
60796070
conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
60806071
return conv.f;
60816072
}
6082-
NK_LIB float
6083-
nk_sqrt(float x)
6084-
{
6085-
return x * nk_inv_sqrt(x);
6086-
}
6073+
#ifndef NK_SIN
6074+
#define NK_SIN nk_sin
60876075
NK_LIB float
60886076
nk_sin(float x)
60896077
{
@@ -6097,6 +6085,9 @@ nk_sin(float x)
60976085
NK_STORAGE const float a7 = +1.38235642404333740e-4f;
60986086
return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
60996087
}
6088+
#endif
6089+
#ifndef NK_COS
6090+
#define NK_COS nk_cos
61006091
NK_LIB float
61016092
nk_cos(float x)
61026093
{
@@ -6113,6 +6104,7 @@ nk_cos(float x)
61136104
NK_STORAGE const float a8 = -1.8776444013090451e-5f;
61146105
return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*(a7 + x*a8)))))));
61156106
}
6107+
#endif
61166108
NK_LIB nk_uint
61176109
nk_round_up_pow2(nk_uint v)
61186110
{
@@ -6346,6 +6338,8 @@ NK_LIB int nk_is_upper(int c){return (c >= 'A' && c <= 'Z') || (c >= 0xC0 && c <
63466338
NK_LIB int nk_to_upper(int c) {return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;}
63476339
NK_LIB int nk_to_lower(int c) {return (c >= 'A' && c <= 'Z') ? (c - ('a' + 'A')) : c;}
63486340

6341+
#ifndef NK_MEMCPY
6342+
#define NK_MEMCPY nk_memcopy
63496343
NK_LIB void*
63506344
nk_memcopy(void *dst0, const void *src0, nk_size length)
63516345
{
@@ -6402,6 +6396,9 @@ nk_memcopy(void *dst0, const void *src0, nk_size length)
64026396
done:
64036397
return (dst0);
64046398
}
6399+
#endif
6400+
#ifndef NK_MEMSET
6401+
#define NK_MEMSET nk_memset
64056402
NK_LIB void
64066403
nk_memset(void *ptr, int c0, nk_size size)
64076404
{
@@ -6453,6 +6450,7 @@ nk_memset(void *ptr, int c0, nk_size size)
64536450
#undef nk_wsize
64546451
#undef nk_wmask
64556452
}
6453+
#endif
64566454
NK_LIB void
64576455
nk_zero(void *ptr, nk_size size)
64586456
{
@@ -6826,6 +6824,8 @@ nk_itoa(char *s, long n)
68266824
nk_strrev_ascii(s);
68276825
return s;
68286826
}
6827+
#ifndef NK_DTOA
6828+
#define NK_DTOA nk_dtoa
68296829
NK_LIB char*
68306830
nk_dtoa(char *s, double n)
68316831
{
@@ -6904,6 +6904,7 @@ nk_dtoa(char *s, double n)
69046904
*(c) = '\0';
69056905
return s;
69066906
}
6907+
#endif
69076908
#ifdef NK_INCLUDE_STANDARD_VARARGS
69086909
#ifndef NK_INCLUDE_STANDARD_IO
69096910
NK_INTERN int
@@ -22185,7 +22186,6 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
2218522186
struct nk_vec2 item_spacing;
2218622187
struct nk_rect header = {0,0,0,0};
2218722188
struct nk_rect sym = {0,0,0,0};
22188-
struct nk_text text;
2218922189

2219022190
nk_flags ws = 0;
2219122191
enum nk_widget_layout_states widget_state;
@@ -22215,14 +22215,12 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
2221522215
const struct nk_style_item *background = &style->tab.background;
2221622216
if (background->type == NK_STYLE_ITEM_IMAGE) {
2221722217
nk_draw_image(out, header, &background->data.image, nk_white);
22218-
text.background = nk_rgba(0,0,0,0);
2221922218
} else {
22220-
text.background = background->data.color;
2222122219
nk_fill_rect(out, header, 0, style->tab.border_color);
2222222220
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
2222322221
style->tab.rounding, background->data.color);
2222422222
}
22225-
} else text.background = style->window.background;
22223+
}
2222622224

2222722225
in = (!(layout->flags & NK_WINDOW_ROM)) ? &ctx->input: 0;
2222822226
in = (in && widget_state == NK_WIDGET_VALID) ? &ctx->input : 0;
@@ -29095,6 +29093,9 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
2909529093
/// - [yy]: Minor version with non-breaking API and library changes
2909629094
/// - [zz]: Bug fix version with no direct changes to API
2909729095
///
29096+
/// - 2020/04/09 (4.02.1) - Removed unused nk_sqrt function to fix compiler warnings
29097+
/// - Fixed compiler warnings if you bring your own methods for
29098+
/// nk_cos/nk_sin/nk_strtod/nk_memset/nk_memcopy/nk_dtoa
2909829099
/// - 2020/04/06 (4.01.10) - Fix bug: Do not use pool before checking for NULL
2909929100
/// - 2020/03/22 (4.01.9) - Fix bug where layout state wasn't restored correctly after
2910029101
/// popping a tree.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuklear",
3-
"version": "4.01.10",
3+
"version": "4.02.1",
44
"repo": "Immediate-Mode-UI/Nuklear",
55
"description": "A small ANSI C gui toolkit",
66
"keywords": ["gl", "ui", "toolkit"],

src/CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
/// - [yy]: Minor version with non-breaking API and library changes
99
/// - [zz]: Bug fix version with no direct changes to API
1010
///
11+
/// - 2020/04/09 (4.02.1) - Removed unused nk_sqrt function to fix compiler warnings
12+
/// - Fixed compiler warnings if you bring your own methods for
13+
/// nk_cos/nk_sin/nk_strtod/nk_memset/nk_memcopy/nk_dtoa
1114
/// - 2020/04/06 (4.01.10) - Fix bug: Do not use pool before checking for NULL
1215
/// - 2020/03/22 (4.01.9) - Fix bug where layout state wasn't restored correctly after
1316
/// popping a tree.

src/nuklear.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3511,7 +3511,10 @@ NK_API int nk_stricmp(const char *s1, const char *s2);
35113511
NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
35123512
NK_API int nk_strtoi(const char *str, const char **endptr);
35133513
NK_API float nk_strtof(const char *str, const char **endptr);
3514+
#ifndef NK_STRTOD
3515+
#define NK_STRTOD nk_strtod
35143516
NK_API double nk_strtod(const char *str, const char **endptr);
3517+
#endif
35153518
NK_API int nk_strfilter(const char *text, const char *regexp);
35163519
NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
35173520
NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score);
@@ -5469,7 +5472,7 @@ template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
54695472
#ifndef STBTT_malloc
54705473
static nk_handle fictional_handle = {0};
54715474

5472-
#define STBTT_malloc(x,u) nk_malloc( fictional_handle, 0, x )
5475+
#define STBTT_malloc(x,u) nk_malloc( fictional_handle, 0, x )
54735476
#define STBTT_free(x,u) nk_mfree( fictional_handle , x)
54745477
#endif
54755478

src/nuklear_internal.h

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,6 @@
2828
#define NK_ASSERT(expr) assert(expr)
2929
#endif
3030

31-
#ifndef NK_MEMSET
32-
#define NK_MEMSET nk_memset
33-
#endif
34-
#ifndef NK_MEMCPY
35-
#define NK_MEMCPY nk_memcopy
36-
#endif
37-
#ifndef NK_SQRT
38-
#define NK_SQRT nk_sqrt
39-
#endif
40-
#ifndef NK_SIN
41-
#define NK_SIN nk_sin
42-
#endif
43-
#ifndef NK_COS
44-
#define NK_COS nk_cos
45-
#endif
46-
#ifndef NK_STRTOD
47-
#define NK_STRTOD nk_strtod
48-
#endif
49-
#ifndef NK_DTOA
50-
#define NK_DTOA nk_dtoa
51-
#endif
52-
5331
#define NK_DEFAULT (-1)
5432

5533
#ifndef NK_VSNPRINTF
@@ -112,9 +90,12 @@ NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255};
11290

11391
/* math */
11492
NK_LIB float nk_inv_sqrt(float n);
115-
NK_LIB float nk_sqrt(float x);
93+
#ifndef NK_SIN
11694
NK_LIB float nk_sin(float x);
95+
#endif
96+
#ifndef NK_COS
11797
NK_LIB float nk_cos(float x);
98+
#endif
11899
NK_LIB nk_uint nk_round_up_pow2(nk_uint v);
119100
NK_LIB struct nk_rect nk_shrink_rect(struct nk_rect r, float amount);
120101
NK_LIB struct nk_rect nk_pad_rect(struct nk_rect r, struct nk_vec2 pad);
@@ -131,12 +112,19 @@ NK_LIB int nk_is_lower(int c);
131112
NK_LIB int nk_is_upper(int c);
132113
NK_LIB int nk_to_upper(int c);
133114
NK_LIB int nk_to_lower(int c);
115+
116+
#ifndef NK_MEMCPY
134117
NK_LIB void* nk_memcopy(void *dst, const void *src, nk_size n);
118+
#endif
119+
#ifndef NK_MEMSET
135120
NK_LIB void nk_memset(void *ptr, int c0, nk_size size);
121+
#endif
136122
NK_LIB void nk_zero(void *ptr, nk_size size);
137123
NK_LIB char *nk_itoa(char *s, long n);
138124
NK_LIB int nk_string_float_limit(char *string, int prec);
125+
#ifndef NK_DTOA
139126
NK_LIB char *nk_dtoa(char *s, double n);
127+
#endif
140128
NK_LIB int nk_text_clamp(const struct nk_user_font *font, const char *text, int text_len, float space, int *glyphs, float *text_width, nk_rune *sep_list, int sep_count);
141129
NK_LIB struct nk_vec2 nk_text_calculate_text_bounds(const struct nk_user_font *font, const char *begin, int byte_len, float row_height, const char **remaining, struct nk_vec2 *out_offset, int *glyphs, int op);
142130
#ifdef NK_INCLUDE_STANDARD_VARARGS

src/nuklear_math.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,8 @@ nk_inv_sqrt(float n)
4545
conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
4646
return conv.f;
4747
}
48-
NK_LIB float
49-
nk_sqrt(float x)
50-
{
51-
return x * nk_inv_sqrt(x);
52-
}
48+
#ifndef NK_SIN
49+
#define NK_SIN nk_sin
5350
NK_LIB float
5451
nk_sin(float x)
5552
{
@@ -63,6 +60,9 @@ nk_sin(float x)
6360
NK_STORAGE const float a7 = +1.38235642404333740e-4f;
6461
return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
6562
}
63+
#endif
64+
#ifndef NK_COS
65+
#define NK_COS nk_cos
6666
NK_LIB float
6767
nk_cos(float x)
6868
{
@@ -79,6 +79,7 @@ nk_cos(float x)
7979
NK_STORAGE const float a8 = -1.8776444013090451e-5f;
8080
return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*(a7 + x*a8)))))));
8181
}
82+
#endif
8283
NK_LIB nk_uint
8384
nk_round_up_pow2(nk_uint v)
8485
{

src/nuklear_tree.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
207207
struct nk_vec2 item_spacing;
208208
struct nk_rect header = {0,0,0,0};
209209
struct nk_rect sym = {0,0,0,0};
210-
struct nk_text text;
211210

212211
nk_flags ws = 0;
213212
enum nk_widget_layout_states widget_state;
@@ -237,14 +236,12 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
237236
const struct nk_style_item *background = &style->tab.background;
238237
if (background->type == NK_STYLE_ITEM_IMAGE) {
239238
nk_draw_image(out, header, &background->data.image, nk_white);
240-
text.background = nk_rgba(0,0,0,0);
241239
} else {
242-
text.background = background->data.color;
243240
nk_fill_rect(out, header, 0, style->tab.border_color);
244241
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
245242
style->tab.rounding, background->data.color);
246243
}
247-
} else text.background = style->window.background;
244+
}
248245

249246
in = (!(layout->flags & NK_WINDOW_ROM)) ? &ctx->input: 0;
250247
in = (in && widget_state == NK_WIDGET_VALID) ? &ctx->input : 0;

0 commit comments

Comments
 (0)