Преглед на файлове

sdl3: Enable compiler warnings

Rob Loach преди 10 месеца
родител
ревизия
1305c18030
променени са 3 файла, в които са добавени 15 реда и са изтрити 2 реда
  1. 10 0
      demo/sdl3/CMakeLists.txt
  2. 3 0
      demo/sdl3/nuklear_sdl3_renderer.c
  3. 2 2
      demo/sdl3/nuklear_sdl3_renderer.h

+ 10 - 0
demo/sdl3/CMakeLists.txt

@@ -40,4 +40,14 @@ if (NUKLEAR_SDL3_EXAMPLES)
 
     # on Visual Studio, set our app as the default project
     set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "nuklear_sdl3_renderer")
+
+    # Enable Warnings
+    if(MSVC)
+        target_compile_options(nuklear_sdl3_renderer PRIVATE /W4 /WX)
+    else()
+        target_compile_options(nuklear_sdl3_renderer PRIVATE -Wall -Wextra -Wpedantic -Werror)
+    endif()
+
+    # SDL3 does not support C89/C90
+    set_property(TARGET nuklear_sdl3_renderer PROPERTY C_STANDARD 99)
 endif()

+ 3 - 0
demo/sdl3/nuklear_sdl3_renderer.c

@@ -87,6 +87,8 @@ SDL_AppResult SDL_Fail(){
 }
 
 SDL_AppResult SDL_AppInit(void** appstate, int argc, char* argv[]) {
+    NK_UNUSED(argc);
+    NK_UNUSED(argv);
     if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS)) {
         return SDL_Fail();
     }
@@ -238,6 +240,7 @@ SDL_AppResult SDL_AppIterate(void *appstate) {
 
 void SDL_AppQuit(void* appstate, SDL_AppResult result) {
     AppContext* app = (AppContext*)appstate;
+    NK_UNUSED(result);
 
     if (app) {
         nk_sdl_shutdown(app->ctx);

+ 2 - 2
demo/sdl3/nuklear_sdl3_renderer.h

@@ -187,18 +187,18 @@ static void
 nk_sdl_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
 {
     const char *text = SDL_GetClipboardText();
+    NK_UNUSED(usr);
     if (text) {
         nk_textedit_paste(edit, text, nk_strlen(text));
         SDL_free((void  *)text);
     }
-    (void)usr;
 }
 
 static void
 nk_sdl_clipboard_copy(nk_handle usr, const char *text, int len)
 {
     char *str = 0;
-    (void)usr;
+    NK_UNUSED(usr);
     if (len <= 0 || text == NULL) return;
     str = SDL_strndup(text, (size_t)len);
     if (str == NULL) return;