Skip to content

Commit

Permalink
Make code compile with stricter gcc/clang warning settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Jul 19, 2023
1 parent 132764e commit d2ab35a
Show file tree
Hide file tree
Showing 91 changed files with 2,742 additions and 1,557 deletions.
14 changes: 8 additions & 6 deletions cmake/target_default_compile_warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ function(target_default_compile_warnings_c THIS)
OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")

target_compile_options(${THIS} PRIVATE
#$<$<CONFIG:RELEASE>:-Werror>
$<$<CONFIG:Debug>:-Wshadow>
$<$<CONFIG:Debug>:-Wunused>
-Wall -Wextra
-Wall -Wextra -Werror
-Wcast-align
-Wpedantic
-Wconversion
-Wsign-conversion
-Wdouble-promotion)
-Wdouble-promotion
-Wno-missing-prototypes
-Wno-missing-variable-declarations)

elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")

target_compile_options(${THIS} PRIVATE
#$<$<CONFIG:RELEASE>:-Werror>
$<$<CONFIG:Debug>:-Wshadow>
$<$<CONFIG:Debug>:-Wunused>
-Wall -Wextra
-Wall -Wextra -Werror
-Wcast-align
-Wpedantic
-Wconversion
-Wsign-conversion
-Wdouble-promotion)
-Wdouble-promotion
-Wno-missing-prototypes
-Wno-missing-variable-declarations)

elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")

Expand Down
2 changes: 1 addition & 1 deletion examples/c/entities/hooks/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {

ecs_trace("ecs_set(world, e, String, {\"Hello World\"})");
ecs_log_push();
ecs_set(world, e, String, {(char*)"Hello World"});
ecs_set(world, e, String, {ECS_CONST_CAST(char*, "Hello World")});
ecs_log_pop();

// This operation changes the entity's archetype, which invokes a move
Expand Down
4 changes: 2 additions & 2 deletions examples/c/rules/basics/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ int main(int argc, char *argv[]) {
// By replacing * with _Food, both terms are constrained to use the
// same entity.
{ .first.id = Eats, .second = {
.name = (char*)"Food", .flags = EcsIsVariable },
.name = "Food", .flags = EcsIsVariable },
},
{ .first.id = Healthy, .src = {
.name = (char*)"Food", .flags = EcsIsVariable }
.name = "Food", .flags = EcsIsVariable }
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions examples/c/rules/cyclic_variables/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ int main(int argc, char *argv[]) {
.terms = {
{
.first.id = Likes,
.src = { .name = (char*)"X", .flags = EcsIsVariable },
.second = { .name = (char*)"Y", .flags = EcsIsVariable }
.src = { .name = "X", .flags = EcsIsVariable },
.second = { .name = "Y", .flags = EcsIsVariable }
},
{
.first.id = Likes,
.src = { .name = (char*)"Y", .flags = EcsIsVariable },
.second = { .name = (char*)"X", .flags = EcsIsVariable }
.src = { .name = "Y", .flags = EcsIsVariable },
.second = { .name = "X", .flags = EcsIsVariable }
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions examples/c/rules/facts/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ int main(int argc, char *argv[]) {
.terms = {
{
.first.id = Likes,
.src = { .name = (char*)"X", .flags = EcsIsVariable },
.second = { .name = (char*)"Y", .flags = EcsIsVariable }
.src = { .name = "X", .flags = EcsIsVariable },
.second = { .name = "Y", .flags = EcsIsVariable }
},
{
.first.id = Likes,
.src = { .name = (char*)"Y", .flags = EcsIsVariable },
.second = { .name = (char*)"X", .flags = EcsIsVariable }
.src = { .name = "Y", .flags = EcsIsVariable },
.second = { .name = "X", .flags = EcsIsVariable }
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions examples/c/rules/setting_variables/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ int main(int argc, char *argv[]) {
{ .first.id = RangedUnit },
{
.first.id = Platoon,
.second = { .name = (char*)"Platoon", .flags = EcsIsVariable },
.second = { .name = "Platoon", .flags = EcsIsVariable },
},
{
.first.id = Player,
.src = { .name = (char*)"Platoon", .flags = EcsIsVariable },
.second = { .name = (char*)"Player", .flags = EcsIsVariable },
.src = { .name = "Platoon", .flags = EcsIsVariable },
.second = { .name = "Player", .flags = EcsIsVariable },
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions examples/c/rules/transitive_queries/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ int main(int argc, char *argv[]) {
{ .id = Person },
{
.first.id = LocatedIn,
.second = { .name = (char*)"Location", .flags = EcsIsVariable },
.second = { .name = "Location", .flags = EcsIsVariable },
},
{
.first.id = Country,
.src = { .name = (char*)"Location", .flags = EcsIsVariable },
.src = { .name = "Location", .flags = EcsIsVariable },
},
}
});
Expand Down
Loading

0 comments on commit d2ab35a

Please sign in to comment.