Skip to content

Commit

Permalink
SanderMertens#70 fix VS 2019 compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rishubn committed Nov 8, 2019
1 parent b5bb22a commit 426081b
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 78 deletions.
138 changes: 138 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,141 @@ bin
.bake_cache
.vscode
gcov
/build/ZERO_CHECK.vcxproj.filters
/build/ZERO_CHECK.vcxproj
/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.vcxproj.FileListAbsolute.txt
/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate
/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog
/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog
/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog
/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.log
/build/x64/Debug/ZERO_CHECK/ZERO_CHECK.Build.CppClean.log
/build/x64/Debug/ALL_BUILD/ALL_BUILD.vcxproj.FileListAbsolute.txt
/build/x64/Debug/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.write.1.tlog
/build/x64/Debug/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.read.1.tlog
/build/x64/Debug/ALL_BUILD/ALL_BUILD.tlog/CustomBuild.command.1.tlog
/build/x64/Debug/ALL_BUILD/ALL_BUILD.tlog/ALL_BUILD.lastbuildstate
/build/x64/Debug/ALL_BUILD/ALL_BUILD.log
/build/x64/Debug/ALL_BUILD/ALL_BUILD.Build.CppClean.log
/build/INSTALL.vcxproj.filters
/build/INSTALL.vcxproj
/build/flecs_static.vcxproj.filters
/build/flecs_static.vcxproj
/build/flecs_static.dir/Debug/world.obj
/build/flecs_static.dir/Debug/worker.obj
/build/flecs_static.dir/Debug/vector.obj
/build/flecs_static.dir/Debug/type.obj
/build/flecs_static.dir/Debug/table.obj
/build/flecs_static.dir/Debug/system.obj
/build/flecs_static.dir/Debug/stats.obj
/build/flecs_static.dir/Debug/stage.obj
/build/flecs_static.dir/Debug/parser.obj
/build/flecs_static.dir/Debug/os_api.obj
/build/flecs_static.dir/Debug/misc.obj
/build/flecs_static.dir/Debug/map.obj
/build/flecs_static.dir/Debug/flecs_static.vcxproj.FileListAbsolute.txt
/build/flecs_static.dir/Debug/flecs_static.tlog/Lib.command.1.tlog
/build/flecs_static.dir/Debug/flecs_static.tlog/Lib-link.write.1.tlog
/build/flecs_static.dir/Debug/flecs_static.tlog/Lib-link.read.1.tlog
/build/flecs_static.dir/Debug/flecs_static.tlog/flecs_static.lastbuildstate
/build/flecs_static.dir/Debug/flecs_static.tlog/CustomBuild.write.1.tlog
/build/flecs_static.dir/Debug/flecs_static.tlog/CustomBuild.read.1.tlog
/build/flecs_static.dir/Debug/flecs_static.tlog/CustomBuild.command.1.tlog
/build/flecs_static.dir/Debug/flecs_static.tlog/CL.write.1.tlog
/build/flecs_static.dir/Debug/flecs_static.tlog/CL.read.1.tlog
/build/flecs_static.dir/Debug/flecs_static.tlog/CL.command.1.tlog
/build/flecs_static.dir/Debug/flecs_static.pdb
/build/flecs_static.dir/Debug/flecs_static.log
/build/flecs_static.dir/Debug/flecs_static.Build.CppClean.log
/build/flecs_static.dir/Debug/err.obj
/build/flecs_static.dir/Debug/entity.obj
/build/flecs_static.dir/Debug/column_system.obj
/build/flecs_static.dir/Debug/chunked.obj
/build/flecs_shared.vcxproj.filters
/build/flecs_shared.vcxproj
/build/flecs_shared.dir/Debug/world.obj
/build/flecs_shared.dir/Debug/worker.obj
/build/flecs_shared.dir/Debug/vector.obj
/build/flecs_shared.dir/Debug/vc142.pdb
/build/flecs_shared.dir/Debug/type.obj
/build/flecs_shared.dir/Debug/table.obj
/build/flecs_shared.dir/Debug/system.obj
/build/flecs_shared.dir/Debug/stats.obj
/build/flecs_shared.dir/Debug/stage.obj
/build/flecs_shared.dir/Debug/parser.obj
/build/flecs_shared.dir/Debug/os_api.obj
/build/flecs_shared.dir/Debug/misc.obj
/build/flecs_shared.dir/Debug/map.obj
/build/flecs_shared.dir/Debug/flecs_shared.vcxproj.FileListAbsolute.txt
/build/flecs_shared.dir/Debug/flecs_shared.tlog/link.write.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.tlog/link.read.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.tlog/link.command.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.tlog/flecs_shared.lastbuildstate
/build/flecs_shared.dir/Debug/flecs_shared.tlog/CustomBuild.write.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.tlog/CustomBuild.read.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.tlog/CustomBuild.command.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.tlog/CL.write.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.tlog/CL.read.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.tlog/CL.command.1.tlog
/build/flecs_shared.dir/Debug/flecs_shared.log
/build/flecs_shared.dir/Debug/flecs_shared.Build.CppClean.log
/build/flecs_shared.dir/Debug/err.obj
/build/flecs_shared.dir/Debug/entity.obj
/build/flecs_shared.dir/Debug/column_system.obj
/build/flecs_shared.dir/Debug/chunked.obj
/build/flecs.sln
/build/Debug/flecs_static.pdb
/build/Debug/flecs_static.lib
/build/Debug/flecs_shared.pdb
/build/Debug/flecs_shared.ilk
/build/Debug/flecs_shared.dll
/build/cmake_install.cmake
/build/CMakeFiles/TargetDirectories.txt
/build/CMakeFiles/generate.stamp.list
/build/CMakeFiles/generate.stamp.depend
/build/CMakeFiles/generate.stamp
/build/CMakeFiles/d8142c6d5c15e95c3eb309a5443776c4/INSTALL_force.rule
/build/CMakeFiles/d8142c6d5c15e95c3eb309a5443776c4/generate.stamp.rule
/build/CMakeFiles/CMakeOutput.log
/build/CMakeFiles/cmake.check_cache
/build/CMakeFiles/3.16.0-rc3/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate
/build/CMakeFiles/3.16.0-rc3/VCTargetsPath.vcxproj
/build/CMakeFiles/3.16.0-rc3/VCTargetsPath.txt
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/Debug/CMakeCCompilerId.obj
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/CompilerIdC.vcxproj
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/CompilerIdC.exe
/build/CMakeFiles/3.16.0-rc3/CompilerIdC/CMakeCCompilerId.c
/build/CMakeFiles/3.16.0-rc3/CMakeSystem.cmake
/build/CMakeFiles/3.16.0-rc3/CMakeRCCompiler.cmake
/build/CMakeFiles/3.16.0-rc3/CMakeDetermineCompilerABI_C.bin
/build/CMakeFiles/3.16.0-rc3/CMakeCCompiler.cmake
/build/CMakeCache.txt
/build/ALL_BUILD.vcxproj.user
/build/ALL_BUILD.vcxproj.filters
/build/ALL_BUILD.vcxproj
/build/.vs/flecs/v16/Solution.VC.db-wal
/build/.vs/flecs/v16/Solution.VC.db-shm
/build/.vs/flecs/v16/Solution.VC.db
/build/.vs/flecs/v16/ipch/AutoPCH/3b2d0407540ef8fa/COLUMN_SYSTEM.ipch
/build/.vs/flecs/v16/Browse.VC.opendb
/build/.vs/flecs/v16/Browse.VC.db
/build/.vs/flecs/v16/.suo
/build/.vs/flecs/v16/ipch/AutoPCH/e349fd647e044502/MISC.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/d6e78752ff000647/VECTOR.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/c33988ea65e19483/SYSTEM.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/9f22b1c65d564357/STATS.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/8b11fcddd4032241/PARSER.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/7cb77627c65598fe/TYPE.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/734c0713d0f30a7a/MAP.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/6f0bc67a82f9c8d8/TABLE.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/605f85ff3dfbc0fd/ENTITY.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/4d760fe01d80ebc4/WORLD.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/1a91898c113228b0/WORKER.ipch
/build/.vs/flecs/v16/ipch/AutoPCH/12c837dbdc301675/OS_API.ipch
10 changes: 5 additions & 5 deletions include/flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ typedef struct ecs_rows_t {

void *param; /* Userdata passed to on-demand system */
float delta_time; /* Time elapsed since last frame */
float world_time; /* Time elapsed since start of simulation */
double world_time; /* Time elapsed since start of simulation */
uint32_t frame_offset; /* Offset relative to frame */
uint32_t table_offset; /* Current active table being processed */
uint32_t offset; /* Offset relative to current table */
uint32_t count; /* Number of rows to process by system */
uint32_t table_offset; /* Current active table being processed */
uint32_t offset; /* Offset relative to current table */
uint32_t count; /* Number of rows to process by system */

ecs_entity_t interrupted_by; /* When set, system execution is interrupted */
} ecs_rows_t;
Expand Down Expand Up @@ -1146,7 +1146,7 @@ ecs_entity_t _ecs_set_ptr(
ecs_entity_t entity,
ecs_entity_t component,
size_t size,
void *ptr);
const void *ptr);

FLECS_EXPORT
ecs_entity_t _ecs_set_singleton_ptr(
Expand Down
2 changes: 1 addition & 1 deletion include/flecs/util/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ FLECS_EXPORT
bool _ecs_map_has(
ecs_map_t *map,
uint64_t key_hash,
void *value_out,
const void *value_out,
uint32_t size);

#define ecs_map_has(map, key, data)\
Expand Down
7 changes: 5 additions & 2 deletions include/flecs/util/os_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#if defined(_MSC_VER) || defined(__MINGW32__)
#include <malloc.h>
#pragma warning(disable:4996) // disable _CRT_SECURE_NO_WARNINGS in MSVC
#else
#include <alloca.h>
#endif
Expand Down Expand Up @@ -210,8 +211,10 @@ void ecs_os_set_api_defaults(void);
#define ecs_os_strdup(str) ecs_os_api.strdup(str)

#if defined(_MSC_VER) || defined(__MINGW32__)
#define ecs_os_alloca(type, count) _alloca(sizeof(type) * (count))
#define _ecs_os_alloca(size, count) _alloca((size) * (count))
#define ecs_os_alloca(type, count) _alloca(sizeof(type) * (count)) \
__pragma(warning(disable:6255))
#define _ecs_os_alloca(size, count) _alloca((size) * (count)) \
__pragma(warning(disable:6255))
#else
#define ecs_os_alloca(type, count) alloca(sizeof(type) * (count))
#define _ecs_os_alloca(size, count) alloca((size) * (count))
Expand Down
2 changes: 1 addition & 1 deletion src/column_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void add_table(
}

/* Negative number indicates ref instead of offset to ecs_data */
table_data->columns[c] = -ecs_vector_count(table_data->references);
table_data->columns[c] = -(int32_t)(ecs_vector_count(table_data->references));
system_data->base.has_refs = true;
}
}
Expand Down
41 changes: 21 additions & 20 deletions src/entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ ecs_type_t instantiate_prefab(
uint32_t index = entity_info->index + j - 1;
ecs_entity_t entity = entity_ids[index];
ecs_adopt(world, child + j, entity);
ecs_set(world, child + j, EcsId, {op->id});
ecs_set(world, child + j, EcsId, op->id);
}
}
}
Expand Down Expand Up @@ -412,12 +412,12 @@ ecs_type_t copy_from_prefab(
}

ecs_table_column_t *src_column = &prefab_columns[p + 1];
uint32_t size = src_column->size;
uint64_t size = src_column->size;

if (size) {
void *src_column_data = ecs_vector_first(src_column->data);
void *src_ptr = ECS_OFFSET(
src_column_data, size * (prefab_index - 1));
src_column_data, size * ((uint64_t)prefab_index - 1));

uint32_t dst_col_index;
if (info->type == to_add) {
Expand All @@ -429,7 +429,7 @@ ecs_type_t copy_from_prefab(
ecs_table_column_t *dst_column = &columns[dst_col_index + 1];
void *dst_column_data = ecs_vector_first(dst_column->data);
void *dst_ptr = ECS_OFFSET(
dst_column_data, size * (info->index - 1 + offset));
dst_column_data, size * ((uint64_t)info->index - 1 + (uint64_t)offset));

uint32_t i;
for (i = 0; i < limit; i ++) {
Expand Down Expand Up @@ -777,17 +777,19 @@ void* get_ptr_from_prefab(
if (prefab == previous) {
continue;
}
ecs_entity_info_t prefab_info = { .entity = prefab };
if (populate_info(world, &world->main_stage, &prefab_info)) {
if (prefab_info.table != NULL) {
ptr = get_row_ptr(prefab_info.table->type, prefab_info.columns,
prefab_info.index, component);

ecs_entity_info_t prefab_info = {.entity = prefab};
if (populate_info(world, &world->main_stage, &prefab_info)) {
ptr = get_row_ptr(prefab_info.table->type, prefab_info.columns,
prefab_info.index, component);

if (!ptr) {
ptr = get_ptr_from_prefab(
world, stage, &prefab_info, info->entity, component);
}
}
if (!ptr) {
ptr = get_ptr_from_prefab(
world, stage, &prefab_info, info->entity, component);
}
}
}

}

return ptr;
Expand Down Expand Up @@ -1108,9 +1110,9 @@ void copy_column_data(
void *column_data = ecs_vector_first(columns[column + 1].data);

memcpy(
ECS_OFFSET(column_data, (start_row) * size),
ECS_OFFSET(column_data, (uint64_t)(start_row) * size),
data->columns[i],
data->row_count * size
(uint64_t)data->row_count * size
);
}
}
Expand Down Expand Up @@ -1959,7 +1961,7 @@ ecs_entity_t _ecs_set_ptr_intern(
ecs_entity_t entity,
ecs_entity_t component,
size_t size,
void *ptr)
const void *ptr)
{
ecs_assert(world != NULL, ECS_INVALID_PARAMETER, NULL);
ecs_world_t *world_arg = world;
Expand Down Expand Up @@ -2006,7 +2008,7 @@ ecs_entity_t _ecs_set_ptr(
ecs_entity_t entity,
ecs_entity_t component,
size_t size,
void *ptr)
const void *ptr)
{
ecs_assert(world != NULL, ECS_INVALID_PARAMETER, NULL);

Expand Down Expand Up @@ -2278,8 +2280,7 @@ ecs_entity_t ecs_new_component(
}

result = _ecs_new(world, world->t_component);
ecs_set(world, result, EcsComponent, {.size = size});
ecs_set(world, result, EcsComponent, {.size = (const uint32_t)size});
ecs_set(world, result, EcsId, {id});

return result;
}
2 changes: 1 addition & 1 deletion src/flecs_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int16_t ecs_table_dim(
uint32_t count);

/* Return number of entities in table */
uint64_t ecs_table_count(
uint32_t ecs_table_count(
ecs_table_t *table);

/* Return size of table row */
Expand Down
20 changes: 10 additions & 10 deletions src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ uint32_t next_bucket(
}
}

return i;
return (uint32_t)i;
}

static
Expand Down Expand Up @@ -232,7 +232,7 @@ void resize_map(
uint32_t bucket_count)
{
uint32_t *old_buckets = map->buckets;
uint32_t old_bucket_count = map->bucket_count;
uint32_t old_bucket_count = (uint32_t)map->bucket_count;

alloc_buffer(map, bucket_count);
map->count = 0;
Expand Down Expand Up @@ -269,13 +269,13 @@ ecs_map_t* ecs_map_new(
if (!data_size) {
data_size = sizeof(uint64_t);
}
return alloc_map((float)size / FLECS_LOAD_FACTOR, data_size);
return alloc_map((uint32_t)(size / FLECS_LOAD_FACTOR), data_size);
}

void ecs_map_clear(
ecs_map_t *map)
{
uint32_t target_size = (float)map->count / FLECS_LOAD_FACTOR;
uint32_t target_size = (uint32_t)((float)map->count / FLECS_LOAD_FACTOR);

if (target_size < map->min) {
target_size = map->min;
Expand Down Expand Up @@ -311,10 +311,10 @@ void* _ecs_map_set(
(void)size;
ecs_assert(ecs_map_data_size(map) == size, ECS_INVALID_PARAMETER, NULL);

uint32_t bucket_count = map->bucket_count;
uint32_t bucket_count = (uint32_t)(map->bucket_count);
if (!bucket_count) {
alloc_buffer(map, 2);
bucket_count = map->bucket_count;
bucket_count = (uint32_t)(map->bucket_count);
}

if ((((float)map->count) / (float)bucket_count) > FLECS_LOAD_FACTOR) {
Expand Down Expand Up @@ -441,15 +441,15 @@ uint32_t ecs_map_count(
uint32_t ecs_map_bucket_count(
ecs_map_t *map)
{
return map->bucket_count;
return (uint32_t)map->bucket_count;
}

uint32_t ecs_map_set_size(
ecs_map_t *map,
uint32_t size)
{
uint32_t result = ecs_vector_set_size(&map->nodes, &map->node_params, size);
resize_map(map, size / FLECS_LOAD_FACTOR);
resize_map(map, (uint32_t)(size / FLECS_LOAD_FACTOR));
return result;
}

Expand All @@ -475,7 +475,7 @@ void ecs_map_memory(

if (total) {

*total += map->bucket_count * sizeof(uint32_t) + sizeof(ecs_map_t);
*total += (uint32_t)(map->bucket_count) * (uint32_t)(sizeof(uint32_t) + sizeof(ecs_map_t));
ecs_vector_memory(map->nodes, &map->node_params, total, NULL);
}

Expand Down Expand Up @@ -574,5 +574,5 @@ void* ecs_map_next_w_size(
uint32_t ecs_map_data_size(
ecs_map_t *map)
{
return data_size(map);
return (uint32_t)(data_size(map));
}
Loading

0 comments on commit 426081b

Please sign in to comment.