NO WARNINGS

This commit is contained in:
veclav talica 2024-08-27 13:42:40 +03:00
parent 93f61018cd
commit 66c90181cd
7 changed files with 17 additions and 6 deletions

View File

@ -164,6 +164,7 @@ function(give_options target)
-Wdouble-promotion -Wdouble-promotion
-Wconversion -Wno-sign-conversion -Wconversion -Wno-sign-conversion
-Werror=vla -Werror=vla
-Wno-missing-field-initializers
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Gnu>:-Wcast-align=strict>) $<$<STREQUAL:${CMAKE_C_COMPILER_ID},Gnu>:-Wcast-align=strict>)
target_compile_options(${target} PRIVATE target_compile_options(${target} PRIVATE

View File

@ -20,8 +20,6 @@ void game_tick(void) {
state->scene = title_scene(state); state->scene = title_scene(state);
} }
struct state *state = ctx.udata;
input_add_action(&ctx.input, "debug_dump_atlases"); input_add_action(&ctx.input, "debug_dump_atlases");
input_bind_action_scancode(&ctx.input, "debug_dump_atlases", SDL_SCANCODE_HOME); input_bind_action_scancode(&ctx.input, "debug_dump_atlases", SDL_SCANCODE_HOME);

View File

@ -59,7 +59,7 @@ static void ingame_tick(struct state *state) {
m_set(rect, ((t_frect){ 256, 256, 48, 48 })), m_set(rect, ((t_frect){ 256, 256, 48, 48 })),
m_opt(color, ((t_color){ 255, 255, 255, 255 })), m_opt(color, ((t_color){ 255, 255, 255, 255 })),
m_opt(stretch, false ), m_opt(stretch, false ),
m_opt(texture_origin, ((t_fvec2){ ctx.tick_count % 48, ctx.tick_count % 48 }))); m_opt(texture_origin, ((t_fvec2){ (float)(ctx.tick_count % 48), (float)(ctx.tick_count % 48) })));
m_sprite(m_set(path, "/assets/light.png"), m_sprite(m_set(path, "/assets/light.png"),
m_set(rect, ((t_frect){ 48, 64, 64, 64 })), m_set(rect, ((t_frect){ 48, 64, 64, 64 })),

View File

@ -18,13 +18,13 @@ static void title_tick(struct state *state) {
m_sprite("/assets/title.png", ((t_frect) { m_sprite("/assets/title.png", ((t_frect) {
(RENDER_BASE_WIDTH / 2) - (320 / 2), 64, 320, 128 })); ((float)RENDER_BASE_WIDTH / 2) - ((float)320 / 2), 64, 320, 128 }));
/* draw the tick count as an example of dynamic text */ /* draw the tick count as an example of dynamic text */
size_t text_str_len = snprintf(NULL, 0, "%lld", state->ctx->tick_count) + 1; size_t text_str_len = snprintf(NULL, 0, "%lu", state->ctx->tick_count) + 1;
char *text_str = cmalloc(text_str_len); char *text_str = cmalloc(text_str_len);
snprintf(text_str, text_str_len, "%lld", state->ctx->tick_count); snprintf(text_str, text_str_len, "%lu", state->ctx->tick_count);
const char *font = "fonts/kenney-pixel.ttf"; const char *font = "fonts/kenney-pixel.ttf";
int text_h = 32; int text_h = 32;

View File

@ -37,6 +37,9 @@ static void load_game_object(void) {
goto ERR_OPENING_SO; goto ERR_OPENING_SO;
} }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
game_tick_callback = (void (*)(void))dlsym(new_handle, "game_tick"); game_tick_callback = (void (*)(void))dlsym(new_handle, "game_tick");
if (!game_tick_callback) { if (!game_tick_callback) {
CRY("Hot Reload Error", "game_tick_callback() symbol wasn't found"); CRY("Hot Reload Error", "game_tick_callback() symbol wasn't found");
@ -49,6 +52,8 @@ static void load_game_object(void) {
goto ERR_GETTING_PROC; goto ERR_GETTING_PROC;
} }
#pragma GCC diagnostic pop
handle = new_handle; handle = new_handle;
if (ctx.tick_count != 0) if (ctx.tick_count != 0)

View File

@ -29,6 +29,9 @@ static void load_game_object(void) {
goto ERR_OPENING_SO; goto ERR_OPENING_SO;
} }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
game_tick_callback = (void (*)(void))GetProcAddress(new_handle, "game_tick"); game_tick_callback = (void (*)(void))GetProcAddress(new_handle, "game_tick");
if (!game_tick_callback) { if (!game_tick_callback) {
CRY("Hot Reload Error", "game_tick_callback() symbol wasn't found"); CRY("Hot Reload Error", "game_tick_callback() symbol wasn't found");
@ -41,6 +44,8 @@ static void load_game_object(void) {
goto ERR_GETTING_PROC; goto ERR_GETTING_PROC;
} }
#pragma GCC diagnostic pop
handle = new_handle; handle = new_handle;
if (ctx.tick_count != 0) if (ctx.tick_count != 0)

View File

@ -303,12 +303,14 @@ t_fvec2 input_get_action_position(struct input_state *input, char *action_name)
void input_set_mouse_captured(struct input_state *input, bool enabled) { void input_set_mouse_captured(struct input_state *input, bool enabled) {
(void)input;
/* TODO: returns -1 if not supported, but like... do we care? */ /* TODO: returns -1 if not supported, but like... do we care? */
SDL_SetRelativeMouseMode(enabled); SDL_SetRelativeMouseMode(enabled);
} }
bool input_is_mouse_captured(struct input_state *input) { bool input_is_mouse_captured(struct input_state *input) {
(void)input;
return SDL_GetRelativeMouseMode(); return SDL_GetRelativeMouseMode();
} }