From f57d18ad744722213e7786584cfd4f858d2eaf76 Mon Sep 17 00:00:00 2001 From: jamesvert Date: Tue, 26 Mar 2024 11:06:16 +0000 Subject: [PATCH 1/2] Fix C4018 warnings in MSVC on WIN32 --- tiny_gltf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index f1c618e..79b37dd 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -3019,12 +3019,12 @@ bool GetFileSizeInBytes(size_t *filesize_out, std::string *err, } f.seekg(0, f.end); - size_t sz = static_cast(f.tellg()); + const auto sz = f.tellg(); // std::cout << "sz = " << sz << "\n"; f.seekg(0, f.beg); - if (int64_t(sz) < 0) { + if (sz < 0) { if (err) { (*err) += "Invalid file size : " + filepath + " (does the path point to a directory?)"; @@ -3114,12 +3114,12 @@ bool ReadWholeFile(std::vector *out, std::string *err, } f.seekg(0, f.end); - size_t sz = static_cast(f.tellg()); + const auto sz = f.tellg(); // std::cout << "sz = " << sz << "\n"; f.seekg(0, f.beg); - if (int64_t(sz) < 0) { + if (sz < 0) { if (err) { (*err) += "Invalid file size : " + filepath + " (does the path point to a directory?)"; From e3f9a7d8b33a78bbe4606a934c6a9be5e402fab0 Mon Sep 17 00:00:00 2001 From: jamesvert Date: Tue, 26 Mar 2024 11:32:43 +0000 Subject: [PATCH 2/2] Resolve overload ambiguity in VS2015 (version 14.0) --- tiny_gltf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 79b37dd..62006c4 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -3030,7 +3030,7 @@ bool GetFileSizeInBytes(size_t *filesize_out, std::string *err, " (does the path point to a directory?)"; } return false; - } else if (sz == 0) { + } else if (sz == std::streamoff(0)) { if (err) { (*err) += "File is empty : " + filepath + "\n"; } @@ -3125,7 +3125,7 @@ bool ReadWholeFile(std::vector *out, std::string *err, " (does the path point to a directory?)"; } return false; - } else if (sz == 0) { + } else if (sz == std::streamoff(0)) { if (err) { (*err) += "File is empty : " + filepath + "\n"; }