boost 1.57在VC2012里编译出错以及解决
2014-11-17 12:36
211 查看
最新发布的boost版本是在2014年11月3日发布,由于项目里使用,就立即更新为最新版本的库,这样也可以让可能出现的BUG减到最少。
不过在更新这库之后,发现原来可以编译通过的项目,而现在不能通过了,提示错误如下:
transform_width.hpp(156): error C2589: '(' : illegal token on right side of '::'
通过仔细地查看transform_width.hpp文件,发现是其中的std::min使用有问题,因为min函数的两个传入参数类型不一样,这样进行模板
匹配时,就找不到相应的模板。这行代码如下:
unsigned int i = std::min(missing_bits, m_remaining_bits);
通过函数的代码来分析,missing_bits是unsigned int类型,而m_remaining_bits是CHAR类型,导致编译出错。知道了出错的原因,就容易
解决了。把这行代码修改为:
unsigned int i = std::min<unsigned int>(missing_bits, m_remaining_bits);
相关的模板代码:
template<
class Base,
int BitsOut,
int BitsIn,
class CharType
>
void transform_width<Base, BitsOut, BitsIn, CharType>::fill() {
unsigned int missing_bits = BitsOut;
m_buffer_out = 0;
do{
if(0 == m_remaining_bits){
if(m_end_of_sequence){
m_buffer_in = 0;
m_remaining_bits = missing_bits;
}
else{
m_buffer_in = * this->base_reference()++;
m_remaining_bits = BitsIn;
}
}
// append these bits to the next output
// up to the size of the output
修改之前:
unsigned int i = std::min(missing_bits, m_remaining_bits);
把这行修改为:
unsigned int i = std::min<unsigned int>(missing_bits, m_remaining_bits);
// shift interesting bits to least significant position
base_value_type j = m_buffer_in >> (m_remaining_bits - i);
// and mask off the un interesting higher bits
// note presumption of twos complement notation
j &= (1 << i) - 1;
// append then interesting bits to the output value
m_buffer_out <<= i;
m_buffer_out |= j;
// and update counters
missing_bits -= i;
m_remaining_bits -= i;
}while(0 < missing_bits);
m_buffer_out_full = true;
}
蔡军生 QQ: 9073204 深圳
不过在更新这库之后,发现原来可以编译通过的项目,而现在不能通过了,提示错误如下:
transform_width.hpp(156): error C2589: '(' : illegal token on right side of '::'
通过仔细地查看transform_width.hpp文件,发现是其中的std::min使用有问题,因为min函数的两个传入参数类型不一样,这样进行模板
匹配时,就找不到相应的模板。这行代码如下:
unsigned int i = std::min(missing_bits, m_remaining_bits);
通过函数的代码来分析,missing_bits是unsigned int类型,而m_remaining_bits是CHAR类型,导致编译出错。知道了出错的原因,就容易
解决了。把这行代码修改为:
unsigned int i = std::min<unsigned int>(missing_bits, m_remaining_bits);
相关的模板代码:
template<
class Base,
int BitsOut,
int BitsIn,
class CharType
>
void transform_width<Base, BitsOut, BitsIn, CharType>::fill() {
unsigned int missing_bits = BitsOut;
m_buffer_out = 0;
do{
if(0 == m_remaining_bits){
if(m_end_of_sequence){
m_buffer_in = 0;
m_remaining_bits = missing_bits;
}
else{
m_buffer_in = * this->base_reference()++;
m_remaining_bits = BitsIn;
}
}
// append these bits to the next output
// up to the size of the output
修改之前:
unsigned int i = std::min(missing_bits, m_remaining_bits);
把这行修改为:
unsigned int i = std::min<unsigned int>(missing_bits, m_remaining_bits);
// shift interesting bits to least significant position
base_value_type j = m_buffer_in >> (m_remaining_bits - i);
// and mask off the un interesting higher bits
// note presumption of twos complement notation
j &= (1 << i) - 1;
// append then interesting bits to the output value
m_buffer_out <<= i;
m_buffer_out |= j;
// and update counters
missing_bits -= i;
m_remaining_bits -= i;
}while(0 < missing_bits);
m_buffer_out_full = true;
}
蔡军生 QQ: 9073204 深圳
相关文章推荐
- boost 1.57在VC2012里编译出错以及解决
- 编译Android驱动对应的C测试程序出错的解决方法以及正确流程
- 【VC】编译出错is not a class or namespace name的解决办法
- 安装SQL Server 2012过程中出现“启用windows功能NetFx3时出错”(错误原因、详细分析及解决方法)以及在Windows Server2012上安装.NET Framework 3.5的详细分析及安装过程
- 关于scanf与scanf_s的区别,以及用scanf编译出错并且提示找不到可执行文件.exe的解决办法。
- 在安装VC2012上再安装VC2010时连接出错解决
- boost库使用:vs2013下boost::container::vector编译出错解决
- 编译boost程序出现如下错误fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_54.lib'的解决方法
- VC++ 升级到visual studio 2008 后,调试DirectShow中的Sample编译出错问题解决方案
- 在安装VC2012上再安装VC2010时连接出错解决
- 编译boost程序出现如下错误fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_54.lib'的解决方法
- 编译Android驱动对应的C测试程序出错的解决方法以及正确流程
- 部分vc程序编译出错的解决方法
- 编译Android驱动对应的C测试程序出错的解决方法以及正确流程
- 安装SQL Server 2012过程中出现“启用windows功能NetFx3时出错”(错误原因、详细分析及解决方法)以及在Windows Server2012上安装.NET Framework 3
- 数组编译时出错error C2057: expected constant expression,以及解决办法
- 编译boost程序出现如下错误fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_54.lib'的解决方法
- 关于scanf与scanf_s的区别,以及用scanf编译出错并且提示找不到可执行文件.exe的解决办法。
- mini2440之编译busybox-1.22.1c出错以及解决办法