Skip to content

Commit c47bb8f

Browse files
CI: Treat warnings as errors
1 parent f23ad1e commit c47bb8f

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

.github/workflows/ci.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ jobs:
5555
-DCMAKE_BUILD_TYPE=Debug \
5656
-DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} \
5757
-DBUILD_TESTS=ON \
58-
-DBUILD_EXAMPLES=ON
58+
-DBUILD_EXAMPLES=ON \
59+
-DTREAT_WARNINGS_AS_ERRORS=ON
5960
6061
- name: Compile
6162
run: ninja -C build
@@ -254,7 +255,8 @@ jobs:
254255
-DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} \
255256
-DBUILD_TESTS=ON \
256257
-DBUILD_EXAMPLES=ON \
257-
-DINCLUDE_AUDIO_TESTS=OFF
258+
-DINCLUDE_AUDIO_TESTS=OFF \
259+
-DTREAT_WARNINGS_AS_ERRORS=ON
258260
259261
- name: Compile
260262
run: ninja -C build
@@ -366,7 +368,8 @@ jobs:
366368
-DCMAKE_BUILD_TYPE=Debug `
367369
-DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} `
368370
-DBUILD_TESTS=ON `
369-
-DBUILD_EXAMPLES=ON
371+
-DBUILD_EXAMPLES=ON `
372+
-DTREAT_WARNINGS_AS_ERRORS=ON
370373
371374
- name: Compile
372375
run: ninja -C build

examples/event-dispatcher/demo.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using event_dispatcher = cen::event_dispatcher<cen::quit_event,
1010

1111
void on_mouse_button_event(const cen::mouse_button_event& event)
1212
{
13-
cen::log_info("mouse_button_event");
13+
cen::log_info("mouse_button_event (x: %i, y: %i)", event.x(), event.y());
1414
}
1515

1616
// Our AAA game class
@@ -58,7 +58,7 @@ class aaa_game final {
5858
}
5959

6060
// Invoked for each window event
61-
void on_window_event(const cen::window_event&) { cen::log_info("window_event"); }
61+
void on_window_event(const cen::window_event&) {}
6262
};
6363

6464
} // namespace

src/centurion/common/logging.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ inline void set_priority(const log_category category, const log_priority priorit
179179
return SDL_MAX_LOG_MESSAGE;
180180
}
181181

182+
#if defined(__GNUC__) && !defined(__clang__)
183+
#pragma GCC diagnostic push
184+
#pragma GCC diagnostic ignored "-Wformat-security"
185+
#endif // defined(__GNUC__) && !defined(__clang__)
186+
182187
template <typename... Args>
183188
void log(const log_priority priority,
184189
const log_category category,
@@ -192,6 +197,10 @@ void log(const log_priority priority,
192197
std::forward<Args>(args)...);
193198
}
194199

200+
#if defined(__GNUC__) && !defined(__clang__)
201+
#pragma GCC diagnostic pop
202+
#endif // defined(__GNUC__) && !defined(__clang__)
203+
195204
template <typename... Args>
196205
void log_verbose(const log_category category, const char* fmt, Args&&... args) noexcept
197206
{

src/centurion/video/window.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
#include "../common/math.hpp"
3939
#include "../common/primitives.hpp"
40+
#include "../common/utils.hpp"
4041
#include "../detail/owner_handle_api.hpp"
4142
#include "../detail/sdl_deleter.hpp"
4243
#include "../detail/stdlib.hpp"
@@ -208,12 +209,14 @@ class basic_window final {
208209

209210
auto set_fullscreen(const bool enabled) noexcept -> result
210211
{
211-
return SDL_SetWindowFullscreen(mWindow, enabled ? fullscreen : 0) == 0;
212+
const auto flag_value = to_underlying(fullscreen);
213+
return SDL_SetWindowFullscreen(mWindow, enabled ? flag_value : 0) == 0;
212214
}
213215

214216
auto set_fullscreen_desktop(const bool enabled) noexcept -> result
215217
{
216-
return SDL_SetWindowFullscreen(mWindow, enabled ? fullscreen_desktop : 0) == 0;
218+
const auto flag_value = to_underlying(fullscreen_desktop);
219+
return SDL_SetWindowFullscreen(mWindow, enabled ? flag_value : 0) == 0;
217220
}
218221

219222
void set_decorated(const bool decorated) noexcept

test/unit-tests/common/math/point_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ TEST(Point, DistanceInt)
7575
const cen::ipoint b {357, 752};
7676
const auto expected = 780;
7777

78-
ASSERT_FLOAT_EQ(cen::distance(a, b), expected);
79-
ASSERT_FLOAT_EQ(cen::distance(b, a), expected);
78+
ASSERT_EQ(cen::distance(a, b), expected);
79+
ASSERT_EQ(cen::distance(b, a), expected);
8080
}
8181

8282
TEST(Point, DistanceFloat)

0 commit comments

Comments
 (0)