diff options
| author | raysan5 <[email protected]> | 2020-05-06 19:12:09 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-05-06 19:12:09 +0200 |
| commit | fdad1f023b0f4de982957a3baaa41b0ac2666748 (patch) | |
| tree | 3701a104fc5e3250e9e81f8ee46ea4cf3deef824 /src/utils.c | |
| parent | 9a1e934621b6098093d709ceb149f1bb995c15cc (diff) | |
| download | raylib-fdad1f023b0f4de982957a3baaa41b0ac2666748.tar.gz raylib-fdad1f023b0f4de982957a3baaa41b0ac2666748.zip | |
Avoid all MSVC compile warnings
Most warning were related to types conversion (casting required) and unsigned/signed types comparisons.
Added preprocessor directives (_CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE) to avoid warnings about unsafe functions, those functions are safe while used properly and recommended alternatives are MS only.
Some external libraries still generate warnings.
Diffstat (limited to 'src/utils.c')
| -rw-r--r-- | src/utils.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/utils.c b/src/utils.c index 9f4b2ded..c64144a6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -186,7 +186,7 @@ unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead) data = (unsigned char *)RL_MALLOC(sizeof(unsigned char)*size); // NOTE: fread() returns number of read elements instead of bytes, so we read [1 byte, size elements] - unsigned int count = fread(data, sizeof(unsigned char), size, file); + unsigned int count = (unsigned int)fread(data, sizeof(unsigned char), size, file); *bytesRead = count; if (count != size) TRACELOG(LOG_WARNING, "FILEIO: [%s] File partially loaded", fileName); @@ -212,7 +212,7 @@ void SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite) if (file != NULL) { - unsigned int count = fwrite(data, sizeof(unsigned char), bytesToWrite, file); + unsigned int count = (unsigned int)fwrite(data, sizeof(unsigned char), bytesToWrite, file); if (count == 0) TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to write file", fileName); else if (count != bytesToWrite) TRACELOG(LOG_WARNING, "FILEIO: [%s] File partially written", fileName); @@ -241,13 +241,13 @@ char *LoadFileText(const char *fileName) // text mode causes carriage return-linefeed translation... // ...but using fseek() should return correct byte-offset fseek(textFile, 0, SEEK_END); - int size = ftell(textFile); + unsigned int size = (unsigned int)ftell(textFile); fseek(textFile, 0, SEEK_SET); if (size > 0) { text = (char *)RL_MALLOC(sizeof(char)*(size + 1)); - int count = fread(text, sizeof(char), size, textFile); + unsigned int count = (unsigned int)fread(text, sizeof(char), size, textFile); // WARNING: \r\n is converted to \n on reading, so, // read bytes count gets reduced by the number of lines |
