|
Boost Users : |
Subject: [Boost-users] [filesystem] VS2005 compiler warnings
From: Klebsch, Mario (Mario.Klebsch_at_[hidden])
Date: 2018-01-09 11:48:24
Hi,
I am using boost library 1.63.0 in an old project, which still uses VS2005. I get some compiler warnings from boost::filesystem:
boost\libs\filesystem\src\unique_path.cpp(114) : warning C4267: 'argument' : conversion from 'size_t' to 'DWORD', possible loss of data
boost\libs\filesystem\src\windows_file_codecvt.cpp(43) : warning C4244: 'argument' : conversion from '__w64 int' to 'int', possible loss of data
boost\libs\filesystem\src\windows_file_codecvt.cpp(43) : warning C4244: 'argument' : conversion from '__w64 int' to 'int', possible loss of data
boost\libs\filesystem\src\windows_file_codecvt.cpp(63) : warning C4244: 'argument' : conversion from '__w64 int' to 'int', possible loss of data
boost\libs\filesystem\src\windows_file_codecvt.cpp(63) : warning C4244: 'argument' : conversion from '__w64 int' to 'int', possible loss of data
boost\boost\filesystem\string_file.hpp(27) : warning C4267: 'argument' : conversion from 'size_t' to 'std::streamsize', possible loss of data
boost\boost\filesystem\string_file.hpp(38) : warning C4267: 'argument' : conversion from 'size_t' to 'std::streamsize', possible loss of data
I am new on boost-users, so I don't yet know, whether patches for compiler warnings are welcome, but I would like to propose some changes:
For the warning in unique_path.cpp(114),I think it is safe to static_cast len to DWORD:
> BOOL gen_ok = ::CryptGenRandom(handle, static_cast <DWORD>(len), static_cast<unsigned char*>(buf));
For the two lines in windows_file_codecvt.cpp, I also think that a static_cast is ok:
windows_file_codecvt.cpp(42) > if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from,
windows_file_codecvt.cpp(43) > static_cast<int>(from_end - from), to, static_cast<int>(to_end - to))) == 0)
windows_file_codecvt.cpp(62) > if ((count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from,
windows_file_codecvt.cpp(63) > static_cast<int>(from_end - from), to, static_cast<int>(to_end - to), 0, 0)) == 0)
The last two warnings are in generic parts, and changes would affect not only windows. Unfortunately, I have no good idea, on how to fix or avoid these warnings.
73, Mario
-- Mario Klebsch Actia I+ME GmbH Mario.klebsch_at_[hidden]<mailto:Mario.klebsch_at_[hidden]> Dresdenstrasse 17/18 Fon: +49 531 38 701 716 38124 Braunschweig Fax: +49 531 38 701 88 Germany
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net