From: outfrost Date: Sun, 5 Jul 2020 03:50:11 +0000 (+0200) Subject: Add prelude with UNUSED macro X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=b89e6619afe25d87c3bcad49df9e3010fe61060e;p=shadowclad.git Add prelude with UNUSED macro --- diff --git a/src/engine/_prelude.h b/src/engine/_prelude.h new file mode 100644 index 0000000..a97c9ba --- /dev/null +++ b/src/engine/_prelude.h @@ -0,0 +1,14 @@ +#ifndef ENGINE_PRELUDE_H_ +#define ENGINE_PRELUDE_H_ + +#ifdef __GNUC__ + +# define UNUSED __attribute__((unused)) + +#else // __GNUC__ + +# define UNUSED + +#endif // __GNUC__ + +#endif // ENGINE_PRELUDE_H_ diff --git a/src/engine/engine.c b/src/engine/engine.c index 34c6d14..1e7849f 100644 --- a/src/engine/engine.c +++ b/src/engine/engine.c @@ -5,6 +5,7 @@ #include #include +#include "_prelude.h" #include "input.h" #include "logger.h" #include "performance.h" @@ -111,6 +112,6 @@ EngineConfig defaultConfig() { .swapInterval = 1 }; } -static void onGlfwError(int error, const char* description) { +static void onGlfwError(int error UNUSED, const char* description) { logError("GLFW error: %s", description); } diff --git a/src/engine/input.c b/src/engine/input.c index b843143..df33578 100644 --- a/src/engine/input.c +++ b/src/engine/input.c @@ -2,13 +2,14 @@ #include +#include "_prelude.h" #include "render.h" static void (*keyboardInputCallback) (int, int, int, int); -void onKeyboardEvent(GLFWwindow* window, int key, int scancode, int action, int mods) { +void onKeyboardEvent(GLFWwindow* window UNUSED, int key, int scancode, int action, int mods) { if (!(mods & GLFW_MOD_CONTROL)) { if (keyboardInputCallback) { keyboardInputCallback(key, scancode, action, mods); diff --git a/src/engine/ui.c b/src/engine/ui.c index 7a8da1d..3bd283a 100644 --- a/src/engine/ui.c +++ b/src/engine/ui.c @@ -1,8 +1,9 @@ #include "ui.h" +#include "_prelude.h" #include "render.h" -void resizeStage(GLFWwindow* window, int width, int height) { +void resizeStage(GLFWwindow* window UNUSED, int width, int height) { if (height == 0) height = 1; diff --git a/src/game/input.c b/src/game/input.c index f52a27e..089291a 100644 --- a/src/game/input.c +++ b/src/game/input.c @@ -2,9 +2,11 @@ #include +#include "engine/_prelude.h" + #include "player.h" -void keyboardInput(int key, int scancode, int action, int mods) { +void keyboardInput(int key, int scancode UNUSED, int action, int mods UNUSED) { switch (key) { case GLFW_KEY_W: if (action == GLFW_PRESS) {