diff --git a/CMakeLists.txt b/CMakeLists.txt index 13787cb2..90218e7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,11 @@ if(PSEMEK_BUILD_TYPE STREQUAL "DEBUG") list(APPEND PSEMEK_DEFINITIONS "-DPSEMEK_DEBUG=1") endif() +set(PSEMEK_CXX_FLAGS) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) + list(APPEND PSEMEK_CXX_FLAGS -Wall -Werror -Wextra -pedantic) +endif() + add_subdirectory(tools) add_subdirectory(libs) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 6ce71d8a..cfdf65e0 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -4,6 +4,7 @@ list(REMOVE_ITEM PSEMEK_LIBRARIES "CMakeLists.txt") foreach(lib ${PSEMEK_LIBRARIES}) add_subdirectory(${lib}) target_compile_definitions(${lib} PUBLIC ${PSEMEK_DEFINITIONS}) + target_compile_options(${lib} PUBLIC ${PSEMEK_CXX_FLAGS}) endforeach() set(PSEMEK_LIBRARIES ${PSEMEK_LIBRARIES} PARENT_SCOPE) diff --git a/libs/app/include/psemek/app/scene.hpp b/libs/app/include/psemek/app/scene.hpp index c65711b5..050e34e6 100644 --- a/libs/app/include/psemek/app/scene.hpp +++ b/libs/app/include/psemek/app/scene.hpp @@ -12,12 +12,12 @@ namespace psemek::app virtual void on_scene_enter() {} virtual void on_scene_exit() {} - virtual void on_resize(int width, int height) {} + virtual void on_resize(int /* width */, int /* height */) {} virtual void on_focus_gained() {} virtual void on_focus_lost() {} - virtual void on_mouse_move(int x, int y) {} - virtual void on_mouse_wheel(int delta) {} + virtual void on_mouse_move(int /* x */, int /* y */) {} + virtual void on_mouse_wheel(int /* delta */) {} virtual void on_left_button_down() {} virtual void on_left_button_up() {} virtual void on_middle_button_down() {} @@ -25,8 +25,8 @@ namespace psemek::app virtual void on_right_button_down() {} virtual void on_right_button_up() {} - virtual void on_key_down(SDL_Keycode key) {} - virtual void on_key_up(SDL_Keycode key) {} + virtual void on_key_down(SDL_Keycode /* key */) {} + virtual void on_key_up(SDL_Keycode /* key */) {} virtual void update() {} virtual void render() {} diff --git a/libs/gfx/source/painter.cpp b/libs/gfx/source/painter.cpp index eca1f83e..79639647 100644 --- a/libs/gfx/source/painter.cpp +++ b/libs/gfx/source/painter.cpp @@ -266,17 +266,17 @@ namespace psemek::gfx for (char c : str) { - if (c < 32 || c > 128) c = '?'; + // Guard against unsigned char +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" + if ((c < 32) || (c >= 128)) c = '?'; +#pragma GCC diagnostic pop int ty = (c - 32) / 16; int tx = (c - 32) % 16; std::uint32_t const base = impl().text_vertices.size(); - geom::point position; - color_rgba color; - geom::point texcoord; - impl().text_vertices.push_back({pen, opts.c, to_texcoord(tx, ty)}); impl().text_vertices.push_back({pen + sx, opts.c, to_texcoord(tx + 1, ty)}); impl().text_vertices.push_back({pen + sy, opts.c, to_texcoord(tx, ty + 1)}); diff --git a/libs/log/include/psemek/log/log.hpp b/libs/log/include/psemek/log/log.hpp index aca6ea1f..562cf3c4 100644 --- a/libs/log/include/psemek/log/log.hpp +++ b/libs/log/include/psemek/log/log.hpp @@ -9,7 +9,7 @@ namespace psemek::log { - void set_max_thread_name_length(int length); + void set_max_thread_name_length(std::size_t length); void register_thread(std::string name); void register_thread(std::thread::id id, std::string name); diff --git a/libs/log/source/log.cpp b/libs/log/source/log.cpp index 46211246..a3f7cc14 100644 --- a/libs/log/source/log.cpp +++ b/libs/log/source/log.cpp @@ -12,9 +12,9 @@ namespace psemek::log { - static int max_thread_name_length = 5; + static std::size_t max_thread_name_length = 5; - void set_max_thread_name_length(int length) + void set_max_thread_name_length(std::size_t length) { max_thread_name_length = length; } diff --git a/libs/pcg/source/blur.cpp b/libs/pcg/source/blur.cpp index ea1fe88d..8c435625 100644 --- a/libs/pcg/source/blur.cpp +++ b/libs/pcg/source/blur.cpp @@ -27,9 +27,9 @@ namespace psemek::pcg auto c = gauss_coeffs(size, sigma); - for (int y = 0; y < p.height(); ++y) + for (std::size_t y = 0; y < p.height(); ++y) { - for (int x = 0; x < p.width(); ++x) + for (std::size_t x = 0; x < p.width(); ++x) { for (int j = - size; j <= size; ++j) { @@ -37,11 +37,11 @@ namespace psemek::pcg { int ix = (x + i); while (ix < 0) ix += p.width(); - if (ix >= p.width()) ix = ix % p.width(); + if (static_cast(ix) >= p.width()) ix = ix % p.width(); int iy = (y + j); while (iy < 0) iy += p.height(); - if (iy >= p.height()) iy = iy % p.height(); + if (static_cast(iy) >= p.height()) iy = iy % p.height(); res(x, y) += p(ix, iy) * c[i + size] * c[j + size]; } diff --git a/libs/util/source/threadpool.cpp b/libs/util/source/threadpool.cpp index ff69ce1b..ca6d46e9 100644 --- a/libs/util/source/threadpool.cpp +++ b/libs/util/source/threadpool.cpp @@ -1,4 +1,5 @@ #include +#include namespace psemek::util { @@ -27,6 +28,7 @@ namespace psemek::util tasks_queue.clear(); for (auto const & thread: threads) { + unused(thread); tasks_queue.push({}); } threads.clear();