From 60c52adfafceb478e9fee571a23e453c0c3df062 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Thu, 16 Dec 2021 19:44:00 +0000 Subject: [PATCH] Enable and fix most GCC warnings (#377) Co-authored-by: Rob Loach --- clib.json | 2 +- demo/allegro5/Makefile | 2 +- demo/allegro5/main.c | 3 - demo/glfw_opengl2/Makefile | 2 +- demo/glfw_opengl2/nuklear_glfw_gl2.h | 1 + demo/glfw_opengl3/Makefile | 2 +- demo/glfw_opengl3/nuklear_glfw_gl3.h | 1 + demo/glfw_opengl4/Makefile | 2 +- demo/glfw_opengl4/nuklear_glfw_gl4.h | 1 + demo/overview.c | 9 -- demo/sdl2surface_rawfb/Makefile | 2 +- demo/sdl2surface_rawfb/main.c | 30 ++++-- demo/sdl2surface_rawfb/sdl2surface_rawfb.h | 18 ++-- demo/sdl_opengl2/Makefile | 2 +- demo/sdl_opengl2/main.c | 3 + demo/sdl_opengl3/Makefile | 2 +- demo/sdl_opengl3/main.c | 3 + demo/sdl_opengles2/Makefile | 2 +- demo/sdl_opengles2/main.c | 4 + demo/sfml_opengl2/Makefile | 2 +- demo/sfml_opengl2/nuklear_sfml_gl2.h | 7 ++ demo/sfml_opengl3/Makefile | 2 +- demo/sfml_opengl3/nuklear_sfml_gl3.h | 7 ++ demo/wayland_rawfb/Makefile | 4 +- demo/wayland_rawfb/main.c | 112 ++++++++++++++++++--- demo/wayland_rawfb/nuklear_raw_wayland.h | 13 ++- demo/x11/Makefile | 2 +- demo/x11/nuklear_xlib.h | 8 ++ demo/x11_opengl2/Makefile | 2 +- demo/x11_opengl2/nuklear_xlib_gl2.h | 5 +- demo/x11_opengl3/Makefile | 2 +- demo/x11_rawfb/Makefile | 2 +- demo/x11_rawfb/nuklear_rawfb.h | 10 +- demo/x11_rawfb/nuklear_xlib.h | 2 +- demo/x11_xft/Makefile | 2 +- demo/x11_xft/nuklear_xlib.h | 16 ++- example/Makefile | 2 +- example/canvas.c | 7 +- example/extended.c | 3 + example/file_browser.c | 5 + example/skinning.c | 3 +- nuklear.h | 3 +- src/CHANGELOG | 1 + src/nuklear_layout.c | 2 +- 44 files changed, 236 insertions(+), 79 deletions(-) diff --git a/clib.json b/clib.json index 49b122d..20e4b9e 100644 --- a/clib.json +++ b/clib.json @@ -1,6 +1,6 @@ { "name": "nuklear", - "version": "4.09.0", + "version": "4.09.1", "repo": "Immediate-Mode-UI/Nuklear", "description": "A small ANSI C gui toolkit", "keywords": ["gl", "ui", "toolkit"], diff --git a/demo/allegro5/Makefile b/demo/allegro5/Makefile index 48e0b7a..d792fa2 100644 --- a/demo/allegro5/Makefile +++ b/demo/allegro5/Makefile @@ -2,7 +2,7 @@ BIN = demo # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/allegro5/main.c b/demo/allegro5/main.c index ea9391b..2755f0d 100644 --- a/demo/allegro5/main.c +++ b/demo/allegro5/main.c @@ -47,9 +47,6 @@ * DEMO * * ===============================================================*/ -static void error_callback(int e, const char *d) -{printf("Error %d: %s\n", e, d);} - int main(void) { /* Platform */ diff --git a/demo/glfw_opengl2/Makefile b/demo/glfw_opengl2/Makefile index ec8bcf3..5b6af64 100644 --- a/demo/glfw_opengl2/Makefile +++ b/demo/glfw_opengl2/Makefile @@ -2,7 +2,7 @@ BIN = demo # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/glfw_opengl2/nuklear_glfw_gl2.h b/demo/glfw_opengl2/nuklear_glfw_gl2.h index a197e90..6eb43cb 100644 --- a/demo/glfw_opengl2/nuklear_glfw_gl2.h +++ b/demo/glfw_opengl2/nuklear_glfw_gl2.h @@ -218,6 +218,7 @@ NK_API void nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { double x, y; + NK_UNUSED(mods); if (button != GLFW_MOUSE_BUTTON_LEFT) return; glfwGetCursorPos(window, &x, &y); if (action == GLFW_PRESS) { diff --git a/demo/glfw_opengl3/Makefile b/demo/glfw_opengl3/Makefile index 57e0936..7c94f3d 100644 --- a/demo/glfw_opengl3/Makefile +++ b/demo/glfw_opengl3/Makefile @@ -2,7 +2,7 @@ BIN = demo # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/glfw_opengl3/nuklear_glfw_gl3.h b/demo/glfw_opengl3/nuklear_glfw_gl3.h index de06b17..ca9a04c 100644 --- a/demo/glfw_opengl3/nuklear_glfw_gl3.h +++ b/demo/glfw_opengl3/nuklear_glfw_gl3.h @@ -330,6 +330,7 @@ nk_glfw3_mouse_button_callback(GLFWwindow* win, int button, int action, int mods { struct nk_glfw* glfw = glfwGetWindowUserPointer(win); double x, y; + NK_UNUSED(mods); if (button != GLFW_MOUSE_BUTTON_LEFT) return; glfwGetCursorPos(win, &x, &y); if (action == GLFW_PRESS) { diff --git a/demo/glfw_opengl4/Makefile b/demo/glfw_opengl4/Makefile index 57e0936..7c94f3d 100644 --- a/demo/glfw_opengl4/Makefile +++ b/demo/glfw_opengl4/Makefile @@ -2,7 +2,7 @@ BIN = demo # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/glfw_opengl4/nuklear_glfw_gl4.h b/demo/glfw_opengl4/nuklear_glfw_gl4.h index 973bfad..6e77627 100644 --- a/demo/glfw_opengl4/nuklear_glfw_gl4.h +++ b/demo/glfw_opengl4/nuklear_glfw_gl4.h @@ -477,6 +477,7 @@ NK_API void nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { double x, y; + NK_UNUSED(mods); if (button != GLFW_MOUSE_BUTTON_LEFT) return; glfwGetCursorPos(window, &x, &y); if (action == GLFW_PRESS) { diff --git a/demo/overview.c b/demo/overview.c index 53c5cb6..b696011 100644 --- a/demo/overview.c +++ b/demo/overview.c @@ -623,13 +623,11 @@ overview(struct nk_context *ctx) int i; int index = -1; - struct nk_rect bounds; /* line chart */ id = 0; index = -1; nk_layout_row_dynamic(ctx, 100, 1); - bounds = nk_widget_bounds(ctx); if (nk_chart_begin(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f)) { for (i = 0; i < 32; ++i) { nk_flags res = nk_chart_push(ctx, (float)cos(id)); @@ -651,7 +649,6 @@ overview(struct nk_context *ctx) /* column chart */ nk_layout_row_dynamic(ctx, 100, 1); - bounds = nk_widget_bounds(ctx); if (nk_chart_begin(ctx, NK_CHART_COLUMN, 32, 0.0f, 1.0f)) { for (i = 0; i < 32; ++i) { nk_flags res = nk_chart_push(ctx, (float)fabs(sin(id))); @@ -672,7 +669,6 @@ overview(struct nk_context *ctx) /* mixed chart */ nk_layout_row_dynamic(ctx, 100, 1); - bounds = nk_widget_bounds(ctx); if (nk_chart_begin(ctx, NK_CHART_COLUMN, 32, 0.0f, 1.0f)) { nk_chart_add_slot(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f); nk_chart_add_slot(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f); @@ -687,7 +683,6 @@ overview(struct nk_context *ctx) /* mixed colored chart */ nk_layout_row_dynamic(ctx, 100, 1); - bounds = nk_widget_bounds(ctx); if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) { nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f); nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,255,0), nk_rgb(0,150,0), 32, -1.0f, 1.0f); @@ -946,7 +941,6 @@ overview(struct nk_context *ctx) if (nk_tree_push(ctx, NK_TREE_NODE, "Notebook", NK_MINIMIZED)) { static int current_tab = 0; - struct nk_rect bounds; float step = (2*3.141592654f) / 32; enum chart_type {CHART_LINE, CHART_HISTO, CHART_MIXED}; const char *names[] = {"Lines", "Columns", "Mixed"}; @@ -982,7 +976,6 @@ overview(struct nk_context *ctx) default: break; case CHART_LINE: nk_layout_row_dynamic(ctx, 100, 1); - bounds = nk_widget_bounds(ctx); if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) { nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f); for (i = 0, id = 0; i < 32; ++i) { @@ -995,7 +988,6 @@ overview(struct nk_context *ctx) break; case CHART_HISTO: nk_layout_row_dynamic(ctx, 100, 1); - bounds = nk_widget_bounds(ctx); if (nk_chart_begin_colored(ctx, NK_CHART_COLUMN, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) { for (i = 0, id = 0; i < 32; ++i) { nk_chart_push_slot(ctx, (float)fabs(sin(id)), 0); @@ -1006,7 +998,6 @@ overview(struct nk_context *ctx) break; case CHART_MIXED: nk_layout_row_dynamic(ctx, 100, 1); - bounds = nk_widget_bounds(ctx); if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) { nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f); nk_chart_add_slot_colored(ctx, NK_CHART_COLUMN, nk_rgb(0,255,0), nk_rgb(0,150,0), 32, 0.0f, 1.0f); diff --git a/demo/sdl2surface_rawfb/Makefile b/demo/sdl2surface_rawfb/Makefile index b1e5830..4fabb13 100644 --- a/demo/sdl2surface_rawfb/Makefile +++ b/demo/sdl2surface_rawfb/Makefile @@ -1,4 +1,4 @@ -CFLAGS=`sdl2-config --cflags --libs` -std=c89 -Wall -O0 -g -fvisibility=hidden -Wno-unused `pkg-config SDL2_ttf --cflags --libs` +CFLAGS=`sdl2-config --cflags --libs` -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O0 -g -fvisibility=hidden `pkg-config SDL2_ttf --cflags --libs` .PHONY: clean diff --git a/demo/sdl2surface_rawfb/main.c b/demo/sdl2surface_rawfb/main.c index 9c25c1e..f383cbc 100644 --- a/demo/sdl2surface_rawfb/main.c +++ b/demo/sdl2surface_rawfb/main.c @@ -2,7 +2,6 @@ #include #include - #ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) #endif @@ -26,6 +25,7 @@ static int translate_sdl_key(struct SDL_Keysym const *k) { /*keyboard handling left as an exercise for the reader */ + NK_UNUSED(k); return NK_KEY_NONE; } @@ -50,7 +50,7 @@ static int sdl_button_to_nk(int button) } } - +#if 0 static void grid_demo(struct nk_context *ctx) { @@ -85,7 +85,7 @@ grid_demo(struct nk_context *ctx) } nk_end(ctx); } - +#endif int main(int argc, char **argv) @@ -93,20 +93,28 @@ int main(int argc, char **argv) struct nk_color clear = {0,100,0,255}; struct nk_vec2 vec; struct nk_rect bounds = {40,40,0,0}; + struct sdlsurface_context *context; + + SDL_DisplayMode dm; + SDL_Window *window; + SDL_Renderer *renderer; + SDL_Texture *tex; + SDL_Surface *surface; + + NK_UNUSED(argc); + NK_UNUSED(argv); SDL_Init(SDL_INIT_VIDEO); printf("sdl init called...\n"); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); - SDL_DisplayMode dm; - SDL_GetDesktopDisplayMode(0, &dm); printf("desktop display mode %d %d\n", dm.w, dm.h); - SDL_Window *window = SDL_CreateWindow("Puzzle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w-200,dm.h-200, SDL_WINDOW_OPENGL); + window = SDL_CreateWindow("Puzzle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w-200,dm.h-200, SDL_WINDOW_OPENGL); if (!window) { printf("can't open window!\n"); @@ -114,18 +122,18 @@ int main(int argc, char **argv) } - SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0); + renderer = SDL_CreateRenderer(window, -1, 0); - SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, dm.w-200, dm.h-200, 32, SDL_PIXELFORMAT_ARGB8888); + surface = SDL_CreateRGBSurfaceWithFormat(0, dm.w-200, dm.h-200, 32, SDL_PIXELFORMAT_ARGB8888); - struct sdlsurface_context *context = nk_sdlsurface_init(surface, 13.0f); + context = nk_sdlsurface_init(surface, 13.0f); while(1) { - nk_input_begin(&(context->ctx)); SDL_Event event; + nk_input_begin(&(context->ctx)); while (SDL_PollEvent(&event)) { switch(event.type) @@ -184,7 +192,7 @@ int main(int argc, char **argv) - SDL_Texture *tex = SDL_CreateTextureFromSurface(renderer, surface); + tex = SDL_CreateTextureFromSurface(renderer, surface); SDL_RenderCopy(renderer, tex, NULL, NULL); SDL_RenderPresent(renderer); SDL_DestroyTexture(tex); diff --git a/demo/sdl2surface_rawfb/sdl2surface_rawfb.h b/demo/sdl2surface_rawfb/sdl2surface_rawfb.h index e36ea31..ce90fba 100644 --- a/demo/sdl2surface_rawfb/sdl2surface_rawfb.h +++ b/demo/sdl2surface_rawfb/sdl2surface_rawfb.h @@ -167,7 +167,7 @@ nk_sdlsurface_img_setpixel(const struct SDL_Surface *img, unsigned int *pixel; NK_ASSERT(img); if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) { - ptr = img->pixels + (img->pitch * y0); + ptr = (unsigned char *)img->pixels + (img->pitch * y0); pixel = (unsigned int *)ptr; if (img->format == NK_FONT_ATLAS_ALPHA8) { @@ -186,7 +186,7 @@ nk_sdlsurface_img_getpixel(const struct SDL_Surface *img, const int x0, const in unsigned int pixel; NK_ASSERT(img); if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) { - ptr = img->pixels + (img->pitch * y0); + ptr = (unsigned char *)img->pixels + (img->pitch * y0); if (img->format == NK_FONT_ATLAS_ALPHA8) { col.a = ptr[x0]; @@ -235,6 +235,8 @@ nk_sdlsurface_stroke_line(const struct sdlsurface_context *sdlsurface, short tmp; int dy, dx, stepx, stepy; + NK_UNUSED(line_thickness); + dy = y1 - y0; dx = x1 - x0; @@ -369,6 +371,8 @@ nk_sdlsurface_stroke_arc(const struct sdlsurface_context *sdlsurface, const int fa2 = 4 * a2, fb2 = 4 * b2; int x, y, sigma; + NK_UNUSED(line_thickness); + if (s != 0 && s != 90 && s != 180 && s != 270) return; if (w < 1 || h < 1) return; @@ -735,6 +739,8 @@ nk_sdlsurface_stroke_circle(const struct sdlsurface_context *sdlsurface, const int fa2 = 4 * a2, fb2 = 4 * b2; int x, y, sigma; + NK_UNUSED(line_thickness); + /* Convert upper left to center */ h = (h + 1) / 2; w = (w + 1) / 2; @@ -802,13 +808,13 @@ nk_sdlsurface_clear(const struct sdlsurface_context *sdlsurface, const struct nk struct sdlsurface_context* nk_sdlsurface_init(SDL_Surface *fb, float fontSize) { - SDL_assert((fb->format->format == SDL_PIXELFORMAT_ARGB8888) - || (fb->format->format == SDL_PIXELFORMAT_RGBA8888)); - const void *tex; int texh, texw; struct sdlsurface_context *sdlsurface; + assert((fb->format->format == SDL_PIXELFORMAT_ARGB8888) + || (fb->format->format == SDL_PIXELFORMAT_RGBA8888)); + sdlsurface = malloc(sizeof(struct sdlsurface_context)); if (!sdlsurface) return NULL; @@ -843,9 +849,9 @@ nk_sdlsurface_init(SDL_Surface *fb, float fontSize) if (fb->format->format == SDL_PIXELFORMAT_RGBA8888) { - SDL_assert(sdlsurface->font_tex->pitch == sdlsurface->font_tex->w * 4); uint32_t *fontPixels = (uint32_t *)sdlsurface->font_tex->pixels; int i; + assert(sdlsurface->font_tex->pitch == sdlsurface->font_tex->w * 4); for (i = 0; i < sdlsurface->font_tex->w * sdlsurface->font_tex->h; i++) { uint32_t col = fontPixels[i]; diff --git a/demo/sdl_opengl2/Makefile b/demo/sdl_opengl2/Makefile index 967e3f6..64f1af3 100644 --- a/demo/sdl_opengl2/Makefile +++ b/demo/sdl_opengl2/Makefile @@ -2,7 +2,7 @@ BIN = demo # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/sdl_opengl2/main.c b/demo/sdl_opengl2/main.c index e649780..309351c 100644 --- a/demo/sdl_opengl2/main.c +++ b/demo/sdl_opengl2/main.c @@ -78,6 +78,9 @@ main(int argc, char *argv[]) struct nk_context *ctx; struct nk_colorf bg; + NK_UNUSED(argc); + NK_UNUSED(argv); + /* SDL setup */ SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0"); SDL_Init(SDL_INIT_VIDEO); diff --git a/demo/sdl_opengl3/Makefile b/demo/sdl_opengl3/Makefile index 1c91995..fb3acd2 100644 --- a/demo/sdl_opengl3/Makefile +++ b/demo/sdl_opengl3/Makefile @@ -2,7 +2,7 @@ BIN = demo # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/sdl_opengl3/main.c b/demo/sdl_opengl3/main.c index c5b95c1..09eb89e 100644 --- a/demo/sdl_opengl3/main.c +++ b/demo/sdl_opengl3/main.c @@ -81,6 +81,9 @@ int main(int argc, char *argv[]) struct nk_context *ctx; struct nk_colorf bg; + NK_UNUSED(argc); + NK_UNUSED(argv); + /* SDL setup */ SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0"); SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS); diff --git a/demo/sdl_opengles2/Makefile b/demo/sdl_opengles2/Makefile index 9c85d89..41d080e 100644 --- a/demo/sdl_opengles2/Makefile +++ b/demo/sdl_opengles2/Makefile @@ -2,7 +2,7 @@ BIN = demo # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/sdl_opengles2/main.c b/demo/sdl_opengles2/main.c index bfb8d9c..e137aee 100644 --- a/demo/sdl_opengles2/main.c +++ b/demo/sdl_opengles2/main.c @@ -139,6 +139,10 @@ int main(int argc, char* argv[]) /* GUI */ struct nk_context *ctx; SDL_GLContext glContext; + + NK_UNUSED(argc); + NK_UNUSED(argv); + /* SDL setup */ SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0"); /*SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS); // - do NOT init SDL on GL ES 2 */ diff --git a/demo/sfml_opengl2/Makefile b/demo/sfml_opengl2/Makefile index 28848a4..e648706 100644 --- a/demo/sfml_opengl2/Makefile +++ b/demo/sfml_opengl2/Makefile @@ -3,7 +3,7 @@ CC = g++ BIN = demo # Flags -CFLAGS += -s -O2 +CFLAGS += -s -Wall -Wextra -pedantic -O2 SRC = main.cpp OBJ = $(SRC:.cpp=.o) diff --git a/demo/sfml_opengl2/nuklear_sfml_gl2.h b/demo/sfml_opengl2/nuklear_sfml_gl2.h index cff7278..728d899 100644 --- a/demo/sfml_opengl2/nuklear_sfml_gl2.h +++ b/demo/sfml_opengl2/nuklear_sfml_gl2.h @@ -189,6 +189,9 @@ nk_sfml_clipboard_paste(nk_handle usr, struct nk_text_edit* edit) if(text) nk_textedit_paste(edit, text, nk_strlen(text)); (void)usr; +#else + NK_UNUSED(usr); + NK_UNUSED(edit); #endif } @@ -208,6 +211,10 @@ nk_sfml_clipboard_copy(nk_handle usr, const char* text, int len) sf::Clipboard clipboard(sfml.window); clipboard.setText(str); free(str); +#else + NK_UNUSED(usr); + NK_UNUSED(text); + NK_UNUSED(len); #endif } diff --git a/demo/sfml_opengl3/Makefile b/demo/sfml_opengl3/Makefile index b30bf28..7bb9712 100644 --- a/demo/sfml_opengl3/Makefile +++ b/demo/sfml_opengl3/Makefile @@ -3,7 +3,7 @@ CC = g++ BIN = demo # Flags -CFLAGS += -s -O2 +CFLAGS += -s -Wall -Wextra -pedantic -O2 SRC = main.cpp OBJ = $(SRC:.cpp=.o) diff --git a/demo/sfml_opengl3/nuklear_sfml_gl3.h b/demo/sfml_opengl3/nuklear_sfml_gl3.h index a074ef0..27d7511 100644 --- a/demo/sfml_opengl3/nuklear_sfml_gl3.h +++ b/demo/sfml_opengl3/nuklear_sfml_gl3.h @@ -298,6 +298,9 @@ nk_sfml_clipboard_paste(nk_handle usr, struct nk_text_edit* edit) sf::Clipboard clipboard(sfml.window); const char* text = clipboard.getText(); if(text) nk_textedit_paste(edit, text, nk_strlen(text)); +#else + NK_UNUSED(usr); + NK_UNUSED(edit); #endif } static void @@ -316,6 +319,10 @@ nk_sfml_clipboard_copy(nk_handle usr, const char* text, int len) sf::Clipboard clipboard(sfml.window); clipboard.setText(str); free(str); +#else + NK_UNUSED(usr); + NK_UNUSED(text); + NK_UNUSED(len); #endif } diff --git a/demo/wayland_rawfb/Makefile b/demo/wayland_rawfb/Makefile index 7359784..7832d68 100644 --- a/demo/wayland_rawfb/Makefile +++ b/demo/wayland_rawfb/Makefile @@ -2,12 +2,12 @@ WAYLAND=`pkg-config wayland-client --cflags --libs` WAYLAND_SCANNER=wayland-scanner WAYLAND_PROTOCOLS_DIR=/usr/share/wayland-protocols -CFLAGS?=-std=c11 -Wall -Werror -O3 -fvisibility=hidden +CFLAGS?=-std=c99 -Wall -Wextra -pedantic -Wno-unused-function -O3 -fvisibility=hidden .PHONY: clean demo: main.c xdg-shell.c xdg-shell.h - $(CC) -o demo *.c $(WAYLAND) -lrt -lm + $(CC) $(CFLAGS) -o demo *.c $(WAYLAND) -lrt -lm xdg-shell.c: $(WAYLAND_SCANNER) code $(WAYLAND_PROTOCOLS_DIR)/stable/xdg-shell/xdg-shell.xml xdg-shell.c diff --git a/demo/wayland_rawfb/main.c b/demo/wayland_rawfb/main.c index fee2945..0db432c 100644 --- a/demo/wayland_rawfb/main.c +++ b/demo/wayland_rawfb/main.c @@ -32,21 +32,37 @@ //WAYLAND OUTPUT INTERFACE static void nk_wayland_output_cb_geometry(void *data, struct wl_output *wl_output, int x, int y, int w, int h, int subpixel, const char *make, const char *model, int transform) { + NK_UNUSED(data); + NK_UNUSED(wl_output); + NK_UNUSED(subpixel); + NK_UNUSED(make); + NK_UNUSED(model); + NK_UNUSED(transform); + printf("wl_output geometry x=%d, y=%d, w=%d, h=%d make=%s, model=%s \n", x,y,w,h, make, model); } static void nk_wayland_output_cb_mode(void *data, struct wl_output *wl_output, unsigned int flags, int w, int h, int refresh) { + NK_UNUSED(data); + NK_UNUSED(wl_output); + NK_UNUSED(flags); + NK_UNUSED(w); + NK_UNUSED(h); + NK_UNUSED(refresh); } static void nk_wayland_output_cb_done(void *data, struct wl_output *output) { - + NK_UNUSED(data); + NK_UNUSED(output); } static void nk_wayland_output_cb_scale(void *data, struct wl_output *output, int scale) { - + NK_UNUSED(data); + NK_UNUSED(output); + NK_UNUSED(scale); } static const struct wl_output_listener nk_wayland_output_listener = @@ -61,15 +77,29 @@ static const struct wl_output_listener nk_wayland_output_listener = //WAYLAND POINTER INTERFACE (mouse/touchpad) static void nk_wayland_pointer_enter (void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { + NK_UNUSED(data); + NK_UNUSED(pointer); + NK_UNUSED(serial); + NK_UNUSED(surface); + NK_UNUSED(surface_x); + NK_UNUSED(surface_y); } static void nk_wayland_pointer_leave (void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface) { + NK_UNUSED(data); + NK_UNUSED(pointer); + NK_UNUSED(serial); + NK_UNUSED(surface); } static void nk_wayland_pointer_motion (void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t x, wl_fixed_t y) { struct nk_wayland* win = (struct nk_wayland*)data; + + NK_UNUSED(pointer); + NK_UNUSED(time); + win->mouse_pointer_x = wl_fixed_to_int(x); win->mouse_pointer_y = wl_fixed_to_int(y); @@ -79,7 +109,11 @@ static void nk_wayland_pointer_motion (void *data, struct wl_pointer *pointer, u static void nk_wayland_pointer_button (void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { struct nk_wayland* win = (struct nk_wayland*)data; - + + NK_UNUSED(pointer); + NK_UNUSED(serial); + NK_UNUSED(time); + if (button == 272){ //left mouse button if (state == WL_POINTER_BUTTON_STATE_PRESSED) { // printf("nk_input_button x=%d, y=%d press: 1 \n", win->mouse_pointer_x, win->mouse_pointer_y); @@ -93,6 +127,11 @@ static void nk_wayland_pointer_button (void *data, struct wl_pointer *pointer, u static void nk_wayland_pointer_axis (void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value) { + NK_UNUSED(data); + NK_UNUSED(pointer); + NK_UNUSED(time); + NK_UNUSED(axis); + NK_UNUSED(value); } static struct wl_pointer_listener nk_wayland_pointer_listener = @@ -101,30 +140,60 @@ static struct wl_pointer_listener nk_wayland_pointer_listener = &nk_wayland_pointer_leave, &nk_wayland_pointer_motion, &nk_wayland_pointer_button, - &nk_wayland_pointer_axis + &nk_wayland_pointer_axis, + NULL, + NULL, + NULL, + NULL }; //-------------------------------------------------------------------- endof WAYLAND POINTER INTERFACE //WAYLAND KEYBOARD INTERFACE static void nk_wayland_keyboard_keymap (void *data, struct wl_keyboard *keyboard, uint32_t format, int32_t fd, uint32_t size) { + NK_UNUSED(data); + NK_UNUSED(keyboard); + NK_UNUSED(format); + NK_UNUSED(fd); + NK_UNUSED(size); } static void nk_wayland_keyboard_enter (void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys) -{ +{ + NK_UNUSED(data); + NK_UNUSED(keyboard); + NK_UNUSED(serial); + NK_UNUSED(surface); + NK_UNUSED(keys); } static void nk_wayland_keyboard_leave (void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface) { + NK_UNUSED(data); + NK_UNUSED(keyboard); + NK_UNUSED(serial); + NK_UNUSED(surface); } static void nk_wayland_keyboard_key (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { + NK_UNUSED(data); + NK_UNUSED(keyboard); + NK_UNUSED(serial); + NK_UNUSED(time); + NK_UNUSED(state); printf("key: %d \n", key); } -static void nk_wayland_keyboard_modifiers (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) +static void nk_wayland_keyboard_modifiers (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { + NK_UNUSED(data); + NK_UNUSED(keyboard); + NK_UNUSED(serial); + NK_UNUSED(mods_depressed); + NK_UNUSED(mods_latched); + NK_UNUSED(mods_locked); + NK_UNUSED(group); } static struct wl_keyboard_listener nk_wayland_keyboard_listener = @@ -133,7 +202,8 @@ static struct wl_keyboard_listener nk_wayland_keyboard_listener = &nk_wayland_keyboard_enter, &nk_wayland_keyboard_leave, &nk_wayland_keyboard_key, - &nk_wayland_keyboard_modifiers + &nk_wayland_keyboard_modifiers, + NULL }; //-------------------------------------------------------------------- endof WAYLAND KEYBOARD INTERFACE @@ -154,14 +224,16 @@ static void seat_capabilities (void *data, struct wl_seat *seat, uint32_t capabi static struct wl_seat_listener seat_listener = { - &seat_capabilities + &seat_capabilities, + NULL }; //-------------------------------------------------------------------- endof WAYLAND SEAT INTERFACE // WAYLAND SHELL INTERFACE static void nk_wayland_xdg_wm_base_ping (void *data, struct xdg_wm_base *xdg_wm_base, uint32_t serial) { - xdg_wm_base_pong (xdg_wm_base, serial); + NK_UNUSED(data); + xdg_wm_base_pong (xdg_wm_base, serial); } static struct xdg_wm_base_listener nk_wayland_xdg_wm_base_listener = @@ -171,6 +243,7 @@ static struct xdg_wm_base_listener nk_wayland_xdg_wm_base_listener = static void nk_wayland_xdg_surface_configure (void *data, struct xdg_surface *xdg_surface, uint32_t serial) { + NK_UNUSED(data); xdg_surface_ack_configure(xdg_surface, serial); } @@ -181,10 +254,17 @@ static struct xdg_surface_listener nk_wayland_xdg_surface_listener = static void nk_wayland_xdg_toplevel_configure (void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height, struct wl_array *states) { + NK_UNUSED(data); + NK_UNUSED(xdg_toplevel); + NK_UNUSED(width); + NK_UNUSED(height); + NK_UNUSED(states); } static void nk_wayland_xdg_toplevel_close (void *data, struct xdg_toplevel *xdg_toplevel) { + NK_UNUSED(data); + NK_UNUSED(xdg_toplevel); } static struct xdg_toplevel_listener nk_wayland_xdg_toplevel_listener = @@ -199,7 +279,9 @@ static struct xdg_toplevel_listener nk_wayland_xdg_toplevel_listener = static void nk_wayland_registry_add_object (void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { struct nk_wayland* win = (struct nk_wayland*)data; - + + NK_UNUSED(version); + //printf("looking for %s interface \n", interface); if (!strcmp(interface,"wl_compositor")) { win->compositor = wl_registry_bind (registry, name, &wl_compositor_interface, 1); @@ -222,6 +304,9 @@ static void nk_wayland_registry_add_object (void *data, struct wl_registry *regi static void nk_wayland_registry_remove_object (void *data, struct wl_registry *registry, uint32_t name) { + NK_UNUSED(data); + NK_UNUSED(registry); + NK_UNUSED(name); } static struct wl_registry_listener nk_wayland_registry_listener = @@ -314,8 +399,10 @@ static void redraw(void *data, struct wl_callback *callback, uint32_t time) { // printf("redrawing.. 1\n"); struct nk_wayland* win = (struct nk_wayland*)data; - struct nk_color col_red = {0xFF,0x00,0x00,0xA0}; //r,g,b,a - struct nk_color col_green = {0x00,0xFF,0x00,0xA0}; //r,g,b,a + + NK_UNUSED(callback); + NK_UNUSED(time); + wl_callback_destroy(win->frame_callback); wl_surface_damage(win->surface, 0, 0, WIDTH, HEIGHT); @@ -338,7 +425,6 @@ int main () long dt; long started; struct nk_wayland nk_wayland_ctx; - struct wl_backend *backend; struct wl_registry *registry; int running = 1; diff --git a/demo/wayland_rawfb/nuklear_raw_wayland.h b/demo/wayland_rawfb/nuklear_raw_wayland.h index 6e18a78..49082c5 100644 --- a/demo/wayland_rawfb/nuklear_raw_wayland.h +++ b/demo/wayland_rawfb/nuklear_raw_wayland.h @@ -110,7 +110,7 @@ static void nk_wayland_ctx_setpixel(const struct nk_wayland* win, const short x0, const short y0, const struct nk_color col) { uint32_t c = nk_color_to_xrgb8888(col); - uint32_t *pixels = win->data; + uint32_t *pixels = (uint32_t *)win->data; unsigned int *ptr; pixels += (y0 * win->width); @@ -252,7 +252,7 @@ static void nk_wayland_img_setpixel(const struct wayland_img *img, const int x0, unsigned int *pixel; NK_ASSERT(img); if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) { - ptr = img->pixels + (img->pitch * y0); + ptr = (unsigned char *)img->pixels + (img->pitch * y0); pixel = (unsigned int *)ptr; if (img->format == NK_FONT_ATLAS_ALPHA8) { @@ -267,10 +267,9 @@ static struct nk_color nk_wayland_getpixel(const struct nk_wayland* win, const i { struct nk_color col = {0, 0, 0, 0}; uint32_t *ptr; - unsigned int pixel; if (y0 < win->height && y0 >= 0 && x0 >= 0 && x0 < win->width) { - ptr = win->data + (y0 * win->width); + ptr = (uint32_t *)win->data + (y0 * win->width); col = nk_wayland_int2color(*ptr, PIXEL_LAYOUT_XRGB_8888); } @@ -285,7 +284,7 @@ static struct nk_color nk_wayland_img_getpixel(const struct wayland_img *img, co unsigned int pixel; NK_ASSERT(img); if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) { - ptr = img->pixels + (img->pitch * y0); + ptr = (unsigned char *)img->pixels + (img->pitch * y0); if (img->format == NK_FONT_ATLAS_ALPHA8) { col.a = ptr[x0]; @@ -365,6 +364,8 @@ static void nk_wayland_stroke_line(const struct nk_wayland* win, short x0, short short tmp; int dy, dx, stepx, stepy; + NK_UNUSED(line_thickness); + dy = y1 - y0; dx = x1 - x0; @@ -494,6 +495,8 @@ static void nk_wayland_stroke_arc(const struct nk_wayland* win, const int fa2 = 4 * a2, fb2 = 4 * b2; int x, y, sigma; + NK_UNUSED(line_thickness); + if (s != 0 && s != 90 && s != 180 && s != 270) return; if (w < 1 || h < 1) return; diff --git a/demo/x11/Makefile b/demo/x11/Makefile index 9057c7b..1234eaf 100644 --- a/demo/x11/Makefile +++ b/demo/x11/Makefile @@ -2,7 +2,7 @@ BIN = zahnrad # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/x11/nuklear_xlib.h b/demo/x11/nuklear_xlib.h index 6701ad9..772ac56 100644 --- a/demo/x11/nuklear_xlib.h +++ b/demo/x11/nuklear_xlib.h @@ -497,6 +497,9 @@ nk_xsurf_draw_image(XSurface *surf, short x, short y, unsigned short w, unsigned struct nk_image img, struct nk_color col) { XImageWithAlpha *aimage = img.handle.ptr; + + NK_UNUSED(col); + if (aimage){ if (aimage->clipMask){ XSetClipMask(surf->dpy, surf->gc, aimage->clipMask); @@ -581,6 +584,9 @@ nk_xfont_get_text_width(nk_handle handle, float height, const char *text, int le { XFont *font = (XFont*)handle.ptr; XRectangle r; + + NK_UNUSED(height); + if(!font || !text) return 0; @@ -687,6 +693,8 @@ nk_xlib_handle_event(Display *dpy, int screen, Window win, XEvent *evt) { struct nk_context *ctx = &xlib.ctx; + NK_UNUSED(screen); + /* optional grabbing behavior */ if (ctx->input.mouse.grab) { XDefineCursor(xlib.dpy, xlib.root, xlib.cursor); diff --git a/demo/x11_opengl2/Makefile b/demo/x11_opengl2/Makefile index 824bc97..e92437f 100644 --- a/demo/x11_opengl2/Makefile +++ b/demo/x11_opengl2/Makefile @@ -6,7 +6,7 @@ CC = clang DCC = gcc # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/x11_opengl2/nuklear_xlib_gl2.h b/demo/x11_opengl2/nuklear_xlib_gl2.h index c8483fe..de720f4 100644 --- a/demo/x11_opengl2/nuklear_xlib_gl2.h +++ b/demo/x11_opengl2/nuklear_xlib_gl2.h @@ -100,8 +100,11 @@ nk_x11_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b /* setup global state */ struct nk_x11_device *dev = &x11.ogl; int width, height; - XWindowAttributes attr; + + NK_UNUSED(max_vertex_buffer); + NK_UNUSED(max_element_buffer); + XGetWindowAttributes(x11.dpy, x11.win, &attr); width = attr.width; height = attr.height; diff --git a/demo/x11_opengl3/Makefile b/demo/x11_opengl3/Makefile index 824bc97..e92437f 100644 --- a/demo/x11_opengl3/Makefile +++ b/demo/x11_opengl3/Makefile @@ -6,7 +6,7 @@ CC = clang DCC = gcc # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/x11_rawfb/Makefile b/demo/x11_rawfb/Makefile index 0cae0b7..10bb4a7 100644 --- a/demo/x11_rawfb/Makefile +++ b/demo/x11_rawfb/Makefile @@ -2,7 +2,7 @@ BIN = zahnrad # Flags -CFLAGS += -std=c89 -pedantic -O2 -Wunused +CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/x11_rawfb/nuklear_rawfb.h b/demo/x11_rawfb/nuklear_rawfb.h index a953993..ce84222 100644 --- a/demo/x11_rawfb/nuklear_rawfb.h +++ b/demo/x11_rawfb/nuklear_rawfb.h @@ -179,7 +179,7 @@ nk_rawfb_img_setpixel(const struct rawfb_image *img, unsigned int *pixel; NK_ASSERT(img); if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) { - ptr = img->pixels + (img->pitch * y0); + ptr = (unsigned char *)img->pixels + (img->pitch * y0); pixel = (unsigned int *)ptr; if (img->format == NK_FONT_ATLAS_ALPHA8) { @@ -198,7 +198,7 @@ nk_rawfb_img_getpixel(const struct rawfb_image *img, const int x0, const int y0) unsigned int pixel; NK_ASSERT(img); if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) { - ptr = img->pixels + (img->pitch * y0); + ptr = (unsigned char *)img->pixels + (img->pitch * y0); if (img->format == NK_FONT_ATLAS_ALPHA8) { col.a = ptr[x0]; @@ -247,6 +247,8 @@ nk_rawfb_stroke_line(const struct rawfb_context *rawfb, short tmp; int dy, dx, stepx, stepy; + NK_UNUSED(line_thickness); + dy = y1 - y0; dx = x1 - x0; @@ -381,6 +383,8 @@ nk_rawfb_stroke_arc(const struct rawfb_context *rawfb, const int fa2 = 4 * a2, fb2 = 4 * b2; int x, y, sigma; + NK_UNUSED(line_thickness); + if (s != 0 && s != 90 && s != 180 && s != 270) return; if (w < 1 || h < 1) return; @@ -747,6 +751,8 @@ nk_rawfb_stroke_circle(const struct rawfb_context *rawfb, const int fa2 = 4 * a2, fb2 = 4 * b2; int x, y, sigma; + NK_UNUSED(line_thickness); + /* Convert upper left to center */ h = (h + 1) / 2; w = (w + 1) / 2; diff --git a/demo/x11_rawfb/nuklear_xlib.h b/demo/x11_rawfb/nuklear_xlib.h index 2f9aa6f..0d23135 100644 --- a/demo/x11_rawfb/nuklear_xlib.h +++ b/demo/x11_rawfb/nuklear_xlib.h @@ -109,7 +109,7 @@ nk_xlib_init(Display *dpy, Visual *vis, int screen, Window root, break; } xlib.xsi.shmaddr = xlib.ximg->data = shmat(xlib.xsi.shmid, NULL, 0); - if ((size_t)xlib.xsi.shmaddr < 0) { + if ((intptr_t)xlib.xsi.shmaddr < 0) { XDestroyImage(xlib.ximg); xlib.fallback = True; break; diff --git a/demo/x11_xft/Makefile b/demo/x11_xft/Makefile index 12d3cba..1ea53e6 100644 --- a/demo/x11_xft/Makefile +++ b/demo/x11_xft/Makefile @@ -2,7 +2,7 @@ BIN = zahnrad # Flags -CFLAGS += -std=c89 -pedantic -O2 +CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2 SRC = main.c OBJ = $(SRC:.c=.o) diff --git a/demo/x11_xft/nuklear_xlib.h b/demo/x11_xft/nuklear_xlib.h index 436307f..7fbcd47 100644 --- a/demo/x11_xft/nuklear_xlib.h +++ b/demo/x11_xft/nuklear_xlib.h @@ -423,10 +423,11 @@ nk_xsurf_draw_text(XSurface *surf, short x, short y, unsigned short w, unsigned #ifdef NK_XLIB_USE_XFT XRenderColor xrc; XftColor color; -#endif - int tx, ty; - unsigned long bg = nk_color_from_byte(&cbg.r); +#else unsigned long fg = nk_color_from_byte(&cfg.r); +#endif + unsigned long bg = nk_color_from_byte(&cbg.r); + int tx, ty; XSetForeground(surf->dpy, surf->gc, bg); XFillRectangle(surf->dpy, surf->drawable, surf->gc, (int)x, (int)y, (unsigned)w, (unsigned)h); @@ -543,6 +544,9 @@ nk_xsurf_draw_image(XSurface *surf, short x, short y, unsigned short w, unsigned struct nk_image img, struct nk_color col) { XImageWithAlpha *aimage = img.handle.ptr; + + NK_UNUSED(col); + if (aimage){ if (aimage->clipMask){ XSetClipMask(surf->dpy, surf->gc, aimage->clipMask); @@ -645,6 +649,8 @@ nk_xfont_get_text_width(nk_handle handle, float height, const char *text, int le #ifdef NK_XLIB_USE_XFT XGlyphInfo g; + NK_UNUSED(height); + if(!font || !text) return 0; @@ -653,6 +659,8 @@ nk_xfont_get_text_width(nk_handle handle, float height, const char *text, int le #else XRectangle r; + NK_UNUSED(height); + if(!font || !text) return 0; @@ -770,6 +778,8 @@ nk_xlib_handle_event(Display *dpy, int screen, Window win, XEvent *evt) { struct nk_context *ctx = &xlib.ctx; + NK_UNUSED(screen); + /* optional grabbing behavior */ if (ctx->input.mouse.grab) { XDefineCursor(xlib.dpy, xlib.root, xlib.cursor); diff --git a/example/Makefile b/example/Makefile index 7d99d77..1f24aea 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,5 +1,5 @@ # Flags -CFLAGS += -std=c99 -pedantic -O2 +CFLAGS += -std=c99 -Wall -Wextra -pedantic -Wno-misleading-indentation -Wno-shift-negative-value -O2 LIBS := ifeq ($(OS),Windows_NT) diff --git a/example/canvas.c b/example/canvas.c index ed7d833..5f651cc 100644 --- a/example/canvas.c +++ b/example/canvas.c @@ -65,6 +65,8 @@ struct device { GLuint font_tex; }; +/* function icon_load () is not used to build this file but might still be useful :) */ +/* static void die(const char *fmt, ...) { @@ -76,8 +78,6 @@ die(const char *fmt, ...) exit(EXIT_FAILURE); } -/* function icon_load () is not used to build this file but might still be useful :) */ -/* static struct nk_image icon_load(const char *filename) { @@ -404,6 +404,9 @@ int main(int argc, char *argv[]) struct nk_font_atlas atlas; struct nk_context ctx; + NK_UNUSED(argc); + NK_UNUSED(argv); + /* GLFW */ glfwSetErrorCallback(error_callback); if (!glfwInit()) { diff --git a/example/extended.c b/example/extended.c index 38be5f6..f1ae3c1 100644 --- a/example/extended.c +++ b/example/extended.c @@ -748,6 +748,9 @@ int main(int argc, char *argv[]) struct media media; struct nk_context ctx; + NK_UNUSED(argc); + NK_UNUSED(argv); + /* GLFW */ glfwSetErrorCallback(error_callback); if (!glfwInit()) { diff --git a/example/file_browser.c b/example/file_browser.c index d77615d..7286d5f 100644 --- a/example/file_browser.c +++ b/example/file_browser.c @@ -149,6 +149,7 @@ die(const char *fmt, ...) exit(EXIT_FAILURE); } +#if 0 static char* file_load(const char* path, size_t* siz) { @@ -163,6 +164,7 @@ file_load(const char* path, size_t* siz) fclose(fd); return buf; } +#endif static char* str_duplicate(const char *src) @@ -200,6 +202,7 @@ dir_list(const char *dir, int return_subdirs, size_t *count) assert(dir); assert(count); strncpy(buffer, dir, MAX_PATH_LEN); + buffer[MAX_PATH_LEN - 1] = 0; n = strlen(buffer); if (n > 0 && (buffer[n-1] != '/')) @@ -343,6 +346,7 @@ static void file_browser_reload_directory_content(struct file_browser *browser, const char *path) { strncpy(browser->directory, path, MAX_PATH_LEN); + browser->directory[MAX_PATH_LEN - 1] = 0; dir_free_list(browser->files, browser->file_count); dir_free_list(browser->directories, browser->dir_count); browser->files = dir_list(path, 0, &browser->file_count); @@ -364,6 +368,7 @@ file_browser_init(struct file_browser *browser, struct media *media) { size_t l; strncpy(browser->home, home, MAX_PATH_LEN); + browser->home[MAX_PATH_LEN - 1] = 0; l = strlen(browser->home); strcpy(browser->home + l, "/"); strcpy(browser->directory, browser->home); diff --git a/example/skinning.c b/example/skinning.c index 84c4bf6..54f71e4 100644 --- a/example/skinning.c +++ b/example/skinning.c @@ -733,7 +733,6 @@ int main(int argc, char *argv[]) nk_input_end(&ctx);} /* GUI */ - {struct nk_panel layout, tab; if (nk_begin(&ctx, "Demo", nk_rect(50, 50, 300, 400), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_TITLE)) { @@ -805,7 +804,7 @@ int main(int argc, char *argv[]) nk_group_end(&ctx); } } - nk_end(&ctx);} + nk_end(&ctx); /* Draw */ glViewport(0, 0, display_width, display_height); diff --git a/nuklear.h b/nuklear.h index ecc3beb..2f7a465 100644 --- a/nuklear.h +++ b/nuklear.h @@ -22166,7 +22166,7 @@ nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx) NK_API void nk_spacer(struct nk_context *ctx ) { - struct nk_rect dummy_rect = {0}; + struct nk_rect dummy_rect = { 0, 0, 0, 0 }; nk_panel_alloc_space( &dummy_rect, ctx ); } @@ -29560,6 +29560,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args) /// - [yy]: Minor version with non-breaking API and library changes /// - [zz]: Bug fix version with no direct changes to API /// +/// - 2021/12/16 (4.09.1) - Fix the majority of GCC warnings /// - 2021/10/16 (4.09.0) - Added nk_spacer() widget /// - 2021/09/22 (4.08.6) - Fix "may be used uninitialized" warnings in nk_widget /// - 2021/09/22 (4.08.5) - GCC __builtin_offsetof only exists in version 4 and later diff --git a/src/CHANGELOG b/src/CHANGELOG index 4e40836..00e3945 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -8,6 +8,7 @@ /// - [yy]: Minor version with non-breaking API and library changes /// - [zz]: Bug fix version with no direct changes to API /// +/// - 2021/12/16 (4.09.1) - Fix the majority of GCC warnings /// - 2021/10/16 (4.09.0) - Added nk_spacer() widget /// - 2021/09/22 (4.08.6) - Fix "may be used uninitialized" warnings in nk_widget /// - 2021/09/22 (4.08.5) - GCC __builtin_offsetof only exists in version 4 and later diff --git a/src/nuklear_layout.c b/src/nuklear_layout.c index b737aca..269cfd4 100644 --- a/src/nuklear_layout.c +++ b/src/nuklear_layout.c @@ -763,7 +763,7 @@ nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx) NK_API void nk_spacer(struct nk_context *ctx ) { - struct nk_rect dummy_rect = {0}; + struct nk_rect dummy_rect = { 0, 0, 0, 0 }; nk_panel_alloc_space( &dummy_rect, ctx ); }