【问题标题】:compiling errors related boost编译错误相关的提升
【发布时间】:2012-12-12 15:55:07
【问题描述】:

当我使用 boost 1.52.1 和 gcc-4.7.1 编译我的代码时,出现以下错误。这似乎是 boost 和 c++ 库之间的冲突。 有人知道如何解决这个问题吗?

非常感谢您的回复。

c:\program files\mingw64\bin\../lib/gcc/x86_64-w64- 
mingw32/4.7.1/../../../../include/boost/math/policies
/error_handling.hpp: In function 'bool    boost::math::policies::
detail::check_overflow(std::complex<T>, 
R*, const char*, const Policy&)':c:\program    
files\mingw64\bin\../lib/gcc/x86_64-w64 mingw32/4.7.1
/../../../../include/boost/math/policies/error_handling.hpp:583:11: 
error: expected unqualified-id before numeric constant
c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-mingw32
/4.7.1/../../../../include/boost/math/policies/error_handling.hpp:
584:49: error: lvalue required as unary '&' operand
 c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/
 ../../../../include/boost/math/policies/
 error_handling.hpp:584:107: error: 'im' was not declared in this
 scope c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-mingw32
 /4.7.1/../../../../include/boost/math/policies/error_handling.
 hpp: In function 'bool boost::math::policies::detail::
 check_underflow(std::complex<T>, R*, const char*, const Policy&)':
 c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-  mingw32
 /4.7.1/../../../../include/boost/math/policies
 /error_handling.hpp:602:11: error: expected unqualified-id before       
 numeric constant c:\program files\mingw64\bin\../lib/gcc/
 x86_64-w64 mingw32/4.7.1/../../../../include/boost/math/policies
 /error_handling.hpp:603:50: error: lvalue required as 
 unary '&' operand c:\program files\mingw64\bin\../lib/gcc/
 x86_64-w64 mingw32/4.7.1/../../../../include/boost/math/policies
 /error_handling .hpp:603:109: error: 'im' was not declared in 
 this scope c:\program files\mingw64\bin\../lib/gcc
 /x86_64-w64-mingw32/4.7.1/../../../../include/boost/math/policies/
 error_handling.hpp: In function 'bool boost::math::policies::
 detail::check_denorm(std::complex<T>, R*, const char*, 
  const Policy&)':c:\program files\mingw64\bin\../lib/gcc
 /x86_64-w64-mingw32/4.7.1/../../../../include/boost/
 math/policies/error_handling.hpp:622:11: error: expected 
 unqualified-id before numeric constant
 c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-
 mingw32/4.7.1/../../../../include/boost/math/policies/
 error_handling.hpp:623:47: error: lvalue required as 
 unary '&' operand
 c:\program files\mingw64\bin\../lib/gcc/x86_64-w64-
 mingw32/4.7.1/../../../../include/boost/math/policies/
 error_handling.hpp:623:103: error: 'im' was not declared
 in this scope

错误出现在代码 boost\math\policy\error_handling.hpp 中。但我不确定程序何时引用这些函数。这个错误是怎么发生的?

template <class R, class T, class Policy>
inline bool check_overflow(std::complex<T> val, R* result, const
char* function, const Policy& pol)
{
    typedef typename R::value_type r_type;
    r_type re, im;
    bool r = check_overflow<r_type>(val.real(), &re, function, pol) || check_overflow<r_type>(val.imag(), &im, function, pol);
    *result = R(re, im);
    return r;
}

 template <class R, class T, class Policy>
 inline bool check_underflow(std::complex<T> val, R* result, const char* function, const Policy& pol)
{
     typedef typename R::value_type r_type;
     r_type re, im;
     bool r = check_underflow<r_type>(val.real(), &re, function, pol) || check_underflow<r_type>(val.imag(), &im, function, pol);
     *result = R(re, im);
     return r;
}

【问题讨论】:

  • 你能发布给出错误的实际代码吗?
  • 此错误出现在文件 boost\math\policy\error_handling.hpp 中,用于两个函数:check_overflow() 和 check_underflow。我不知道有什么问题。什么时候使用这个功能?

标签: c++ eclipse boost compiler-errors


【解决方案1】:

鉴于这两个函数和这个嘈杂的错误消息,我可以说用作参数 R 的类型没有定义 value_type。因此,未定义类型 r_type 和变量 imre。结果你得到error: 'im' was not declared in this scope 错误。

仅使用提供的代码,我可以看到类型 R 具有以下要求:

  • 必须定义类型value_type
  • 它必须有构造函数R(value_type real, value_type imagine)

这意味着你使用了一些不正确地使用内部 check_underflow/check_overflow 函数的 boost 库,我猜是模板参数不兼容。

【讨论】:

  • 是的,你是对的。你有什么建议我应该怎么做?不知道哪里引用了这个函数。
  • 我不知道哪个库使用了这个函数,我虽然那个 gcc 包含 instantinated from here 或类似的错误消息。
  • 我明白了。问题是我使用#define re 1,但是在库中有一个变体也是're'。
  • 请关闭这个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-21
  • 1970-01-01
  • 2012-09-23
  • 1970-01-01
  • 1970-01-01
  • 2014-03-07
相关资源
最近更新 更多