priitj / whitedb

WhiteDB memory database
http://whitedb.org/
GNU General Public License v3.0
608 stars 78 forks source link

Compilation Warnings on Windows (x64) #43

Open rohanbabu opened 5 years ago

rohanbabu commented 5 years ago

Hi, I'm getting the following warnings when I try to build a static library in Visual Studio 2017 for (x64) target, x86 doesn't produce warnings.

  1. Is it safe to ignore or suppress them?
  2. If not, what if any, changes should I be making to the source files?

1>------ Build started: Project: WhiteDB, Configuration: Debug x64 ------ 1>yajl_all.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\yajl_all.c(1816): warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data 1>dbutil.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(202): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(244): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(249): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(293): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(353): warning C4244: '=': conversion from 'int64' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(357): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(378): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(379): warning C4244: '+=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(488): warning C4244: 'function': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(491): warning C4244: 'function': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(526): warning C4244: 'function': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbutil.c(529): warning C4244: 'function': conversion from 'gint' to 'int', possible loss of data 1>dbschema.c 1>dbquery.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbquery.c(254): warning C4244: '=': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbquery.c(290): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbquery.c(420): warning C4244: '=': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbquery.c(1185): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbquery.c(1195): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbquery.c(1205): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbquery.c(1251): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data 1>dbmpool.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbmpool.c(346): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbmpool.c(348): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data 1>dbmem.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbmem.c(312): warning C4244: '=': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbmem.c(676): warning C4133: 'function': incompatible types - from 'char [100]' to 'LPCWSTR' 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbmem.c(741): warning C4244: 'function': conversion from 'gint' to 'DWORD', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbmem.c(742): warning C4133: 'function': incompatible types - from 'char [100]' to 'LPCWSTR' 1>dblog.c 1>dblock.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dblock.c(282): warning C4133: 'function': incompatible types - from 'volatile gint ' to 'volatile LONG ' 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dblock.c(282): warning C4244: 'function': conversion from 'gint' to 'LONG', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dblock.c(362): warning C4133: 'function': incompatible types - from 'volatile gint ' to 'volatile LONG ' 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dblock.c(362): warning C4244: 'function': conversion from 'gint' to 'LONG', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dblock.c(453): warning C4133: 'function': incompatible types - from 'volatile gint ' to 'volatile LONG ' 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dblock.c(453): warning C4244: 'function': conversion from 'gint' to 'LONG', possible loss of data 1>dbjson.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(262): warning C4244: '=': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(218): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(292): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(405): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(762): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(770): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(778): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(785): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(798): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(808): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(815): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(810): warning C4244: 'initializing': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(843): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(855): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(860): warning C4244: 'return': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbjson.c(838): warning C4244: 'initializing': conversion from 'wg_int' to 'int', possible loss of data 1>dbindex.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbindex.c(232): warning C4244: '=': conversion from 'gint' to 'unsigned char', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbindex.c(257): warning C4244: '=': conversion from 'gint' to 'unsigned char', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbindex.c(2300): warning C4244: 'initializing': conversion from 'gint' to 'int', possible loss of data 1>dbhash.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(195): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(315): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(361): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(601): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(637): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(692): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(697): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(750): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(762): warning C4244: '=': conversion from 'gint' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbhash.c(788): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 1>dbdump.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbdump.c(142): warning C4244: 'function': conversion from 'int64' to 'long', possible loss of data 1>dbdata.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbdata.c(1119): warning C4244: '=': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbdata.c(1617): warning C4013: 'floor' undefined; assuming extern returning int 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbdata.c(1665): warning C4244: 'return': conversion from 'wg_int' to 'int', possible loss of data 1>dbcompare.c 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbcompare.c(123): warning C4244: 'initializing': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbcompare.c(124): warning C4244: 'initializing': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbcompare.c(256): warning C4244: 'initializing': conversion from 'wg_int' to 'int', possible loss of data 1>d:\ipc\whitedblib\whitedb\whitedb\src\source\dbcompare.c(257): warning C4244: 'initializing': conversion from 'wg_int' to 'int', possible loss of data 1>dballoc.c 1>Generating Code... 1>WhiteDB.vcxproj -> D:\IPC\WhiteDBLib\WhiteDB\x64\Debug\WhiteDB.lib 1>Done building project "WhiteDB.vcxproj". ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

priitj commented 5 years ago

This has mostly to do with some code assuming int length is the same as word length, which apparently is not true for your x64 Visual Studio build.

There are too many cases to say whether it is safe to ignore them all. In some cases the data probably is never larger than 32 bits, but when it is then it is definitely a problem.