[英]Visual Studio C++ 2005/2010 with boost 1.50: warning C4267
I'm unable to prevent this warning.. 我无法阻止此警告。
...\boost\asio\impl\io_service.ipp(46) : warning C4267: 'argument' : conversion from 'size_t' to 'std::numeric_limits<unsigned int>::_Ty', possible loss of data
Perhaps you got 也许你有
kindly, 亲切,
alex 亚历克斯
an explanation for this
对此的解释
Suspect this is a 64-bit build and size_t
will be 64-bit and unsigned int
will be 32-bit: 怀疑这是一个64位版本,
size_t
将是64位,而unsigned int
将是32位:
std::cout << sizeof(unsigned int) << "\n"; // Output '4' on both x86 and x64
std::cout << sizeof(size_t) << "\n"; // Output '4' on x86
// Output '8' on x64
the solution to prevent the throwing
防止抛出的解决方案
Add the compiler flag /Wd4267
to disable this warning. 添加编译器标志
/Wd4267
以禁用此警告。 However, that would disable the warning for all sources in your project which you may dislike. 但是,这将禁用您可能不喜欢的项目中所有源的警告。 An alternative is to use
#pragma warning
: 一种替代方法是使用
#pragma warning
:
#pragma warning(disable: 4267)
#include <boost-header-files>
#pragma warning(default: 4267)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.