简体   繁体   English

具有Boost 1.50的Visual Studio C ++ 2005/2010:警告C4267

[英]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 也许你有

  1. An explanation for this 对此的解释
  2. The solution to prevent the throwing :-) 防止抛出的解决方案:-)

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.

相关问题 Visual Studio 中的警告 C4267:“参数”:从“size_t”转换为“const _Elem”,可能丢失数据 - Warning C4267 in Visual Studio: 'argument': conversion from 'size_t' to 'const _Elem', possible loss of data 代码中的几行没有收到c4267警告 - Not getting c4267 warning for few lines in code 构造函数中的C4267转换警告 - 无法修复过载? - C4267 conversion warning in constructor - can't fix with overload? 什么是摆脱“警告C4267可能丢失数据”的最佳策略? - What's the best strategy to get rid of “warning C4267 possible loss of data”? 警告C4267:“正在初始化”:从“ size_t”转换为“ UINT” - warning C4267: 'initializing' : conversion from 'size_t' to 'UINT' 警告C4267“正在初始化”:从“ size_t”到“ DWORD”的转换,可能丢失数据 - Warning C4267 'initializing': conversion from 'size_t' to 'DWORD', possible loss of data Visual Studio 2010与Visual Studio 2005 for C ++ - Visual Studio 2010 vs Visual Studio 2005 for C++ Visual Studio 2010中的Visual C ++中的LNK 2005 - LNK 2005 in Visual C++ in Visual Studio 2010 视觉工作室2005年至2010年提升 - visual studio 2005 to 2010 with boost Boost单元测试和Visual Studio 2005 / Visual C ++和BOOST_AUTO_TEST_SUITE(stringtest)命名空间? - Boost Unit Testing and Visual Studio 2005/Visual C++ and the BOOST_AUTO_TEST_SUITE(stringtest) namespace?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM