Skip to content

Commit c56e072

Browse files
committed
fix and turn on compiler warnings
1 parent ecd628d commit c56e072

29 files changed

Lines changed: 32 additions & 50 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,8 @@ check_symbol_exists(pthread_setname_np "pthread.h" DENGINE_HAS_PTHREAD_SETNAME_N
208208
set(CMAKE_REQUIRED_FLAGS "")
209209

210210
configure_file(dengine_config.h.in dengine_config/dengine_config.h)
211-
212-
if (NOT MSVC)
213-
add_compile_options(-Wall)
211+
if(MSYS OR UNIX OR MINGW)
212+
add_compile_options("-Wall" "-Wextra" "-Wformat" "-Wno-unused-parameter")
214213
endif()
215214

216215
set(dengine

lib/dengine-core/include/dengine/shader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int dengine_shader_make_standard(StandardShader stdshader, Shader* shader);
106106

107107
void dengine_shader_set_shadercache(int state);
108108

109-
const uint32_t dengine_shader_sampler2target(const uint32_t sampler);
109+
uint32_t dengine_shader_sampler2target(const uint32_t sampler);
110110

111111
#ifdef __cplusplus
112112
}

lib/dengine-core/src/input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ void _dengine_input_gamepad_linux_resetpads()
474474
}
475475
int _dengine_input_gamepad_linux_getpadfds()
476476
{
477-
int axes = 0;
477+
uint32_t axes = 0;
478478
DIR* dir;
479479
int count = 0;
480480
char path[PATH_MAX];

lib/dengine-core/src/material.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void dengine_material_set_shader_color(const Shader* shader, Material* material)
4545
glGetProgramiv(shader->program_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_uniform_ln); DENGINE_CHECKGL;
4646
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_units); DENGINE_CHECKGL;
4747
char* uniform_name = malloc(max_uniform_ln);
48+
uint32_t max_units_u = max_units;
4849

4950
memset(&material->textures, 0, sizeof(material->textures));
5051
material->textures_count = 0;
@@ -54,7 +55,7 @@ void dengine_material_set_shader_color(const Shader* shader, Material* material)
5455
/*printf("active: %s\n", uniform_name);*/
5556
if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE)
5657
{
57-
if(material->textures_count > max_units)
58+
if(material->textures_count > max_units_u)
5859
{
5960
dengineutils_logging_log("WARNING::This OpenGL driver has a maximum of %d texture units."
6061
"%s will not be activated", max_units, uniform_name);
@@ -81,7 +82,7 @@ void dengine_material_set_shader_color(const Shader* shader, Material* material)
8182
}
8283

8384
//clamp to the max units
84-
if(material->textures_count > max_units)
85+
if(material->textures_count > max_units_u)
8586
material->textures_count = max_units;
8687

8788
free(uniform_name);

lib/dengine-core/src/shader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ void dengine_shader_set_shadercache(int state)
583583
shadercache = state;
584584
}
585585

586-
const uint32_t dengine_shader_sampler2target(const uint32_t sampler)
586+
uint32_t dengine_shader_sampler2target(const uint32_t sampler)
587587
{
588588
DENGINE_DEBUG_ENTER;
589589

lib/dengine-core/src/texture.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void dengine_texture_make_color(const int width, const int height, const float*
268268
{
269269
data = malloc(width * height * channels * sizeof(float));
270270
float* _data = data;
271-
for(size_t i = 0; i < width * height; i++)
271+
for(int i = 0; i < width * height; i++)
272272
{
273273
for(int j = 0; j < channels; j++)
274274
{
@@ -280,7 +280,7 @@ void dengine_texture_make_color(const int width, const int height, const float*
280280
{
281281
data = malloc(width * height * channels);
282282
uint8_t* _data = data;
283-
for(size_t i = 0; i < width * height; i++)
283+
for(int i = 0; i < width * height; i++)
284284
{
285285
for(int j = 0; j < channels; j++)
286286
{

lib/dengine-core/src/window.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
#include "dengine/input.h" //setwindow
88
#include "dengine-utils/logging.h"//log
99
#include "dengine-utils/dynlib.h" //getsym
10-
#include "dengine-utils/thread.h"
1110
#include "dengine-utils/macros.h" //ARY_SZ
12-
#include "dengine-utils/timer.h"
1311
#include "dengine-utils/debug.h"
1412

1513
#include <stdio.h> //printf
@@ -289,7 +287,6 @@ int dengine_window_init()
289287

290288
int init = 0;
291289
#ifdef DENGINE_WIN_X11
292-
XInitThreads();
293290
x_dpy = XOpenDisplay(NULL);
294291
if(x_dpy)
295292
{

lib/dengine-gui/src/gui.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
#include "dengine/input.h"
1111
#include "dengine/entrygl.h"
1212
#include "dengine/viewport.h"
13-
#include "dengine/window.h"
1413

1514
#include "dengine-utils/logging.h"
1615
#include "dengine-utils/debug.h"
17-
#include "dengine-utils/macros.h"
1816

1917
#define STB_TRUETYPE_IMPLEMENTATION
2018
#include <stb_truetype.h> //stbtt
2119

22-
#include "dengine_config.h"
2320
#ifdef DENGINE_ANDROID
2421
#include "dengine-utils/platform/android.h"
2522
#endif
@@ -181,13 +178,12 @@ int denginegui_set_font(const void* ttf, const float fontsize, const uint32_t bi
181178
void* sysfontmem = NULL;
182179
if (!ttf) {
183180
const char* file = _denginegui_get_defaultfont();
184-
FILE* f = fopen(file, "rb");
185-
if (!f) {
186-
dengineutils_logging_log("WARNING::cannot read default font %s", file);
181+
if (file == NULL) {
182+
dengineutils_logging_log("WARNING::Cannot read default font. Load embfont OpenSans_Light");
187183
mem = OpenSans_Light_ttf;
188-
dengineutils_logging_log("WARNING::Load embfont OpenSans_Light");
189184
}else
190185
{
186+
FILE* f = fopen(file, "rb");
191187
fseek(f, 0, SEEK_END);
192188
size_t sz = ftell(f);
193189
rewind(f);

lib/dengine-scene/src/ecs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "dengine-utils/logging.h"
66
#include "dengine_config.h"// DENGINE_ECS_MAXCHILDREN
77
#ifdef DENGINE_SCRIPTING_PYTHON
8-
#include "dengine-script/python/python.h"
98
#include "dengine-scene/scriptingsync/python/entity.h"
109
#endif
1110

lib/dengine-scene/src/scene.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
#include "dengine/viewport.h" //get_view
1616
#include "dengine-script/script.h"
17-
#ifdef DENGINE_SCRIPTING_PYTHON
18-
#include "dengine-script/python/python.h"
19-
#include "dengine-scene/scriptingsync/python/entity.h"
20-
#endif
2117

2218
typedef struct
2319
{

0 commit comments

Comments
 (0)