为什么提升日志中断会提升 GMP 多精度?
Why does boost log break boost GMP multiprecision?
我刚刚在Mac OS Mojave 10.14.6上使用Homebrew将我的提升升级到1.71.0。这样做后,以下程序将无法编译:
#include <boost/log/sinks/text_ostream_backend.hpp>
#include <boost/multiprecision/gmp.hpp>
int main() {}
$ clang++ -v
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ clang++ -std=c++14 boost_gmp.cpp -o boost_gmp
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:284:10: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
if(mpf_sgn(m_data) == 0)
^
/usr/local/include/gmp.h:2239:26: note: expanded from macro 'mpf_sgn'
#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:284:10: error: no member named '_mp_size' in '__mpf_struct'
if(mpf_sgn(m_data) == 0)
^~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2239:26: note: expanded from macro 'mpf_sgn'
#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
~~~ ^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:372:84: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
boost::multiprecision::detail::format_float_string(result, e, org_digits, f, mpf_sgn(m_data) == 0);
^
/usr/local/include/gmp.h:2239:26: note: expanded from macro 'mpf_sgn'
#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:372:84: error: no member named '_mp_size' in '__mpf_struct'
boost::multiprecision::detail::format_float_string(result, e, org_digits, f, mpf_sgn(m_data) == 0);
^~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2239:26: note: expanded from macro 'mpf_sgn'
#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
~~~ ^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1323:27: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
if((base != 10) && (mpz_sgn(m_data) < 0))
^
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1323:27: error: no member named '_mp_size' in '__mpz_struct'
if((base != 10) && (mpz_sgn(m_data) < 0))
^~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
~~~ ^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1364:14: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
return mpz_cmp_si(m_data, i);
^
/usr/local/include/gmp.h:2249:6: note: expanded from macro 'mpz_cmp_si'
? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI))
^
/usr/local/include/gmp.h:2246:6: note: expanded from macro 'mpz_cmp_ui'
? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
^
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1364:14: error: no member named '_mp_size' in '__mpz_struct'
return mpz_cmp_si(m_data, i);
^~~~~~~~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2249:6: note: expanded from macro 'mpz_cmp_si'
? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2246:6: note: expanded from macro 'mpz_cmp_ui'
? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
^~~~~~~~~~~
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
~~~ ^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1369:14: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
return mpz_cmp_ui(m_data, i);
^
/usr/local/include/gmp.h:2246:6: note: expanded from macro 'mpz_cmp_ui'
? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
^
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1369:14: error: no member named '_mp_size' in '__mpz_struct'
return mpz_cmp_ui(m_data, i);
^~~~~~~~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2246:6: note: expanded from macro 'mpz_cmp_ui'
? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
^~~~~~~~~~~
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
~~~ ^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1410:11: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
return mpz_sgn(val.data()) == 0;
^
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1410:11: error: no member named '_mp_size' in '__mpz_struct'
return mpz_sgn(val.data()) == 0;
^~~~~~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
~~~ ^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1653:11: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
return mpz_sgn(val.data());
^
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1653:11: error: no member named '_mp_size' in '__mpz_struct'
return mpz_sgn(val.data());
^~~~~~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
~~~ ^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1657:8: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
if (mpz_sgn(val.data()) < 0)
^
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1657:8: error: no member named '_mp_size' in '__mpz_struct'
if (mpz_sgn(val.data()) < 0)
^~~~~~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
~~~ ^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1668:17: error: no template named '_mp_size'; did you mean 'mp11::mp_size'?
*result = mpz_sgn(val.data()) < 0 ? (std::numeric_limits<long>::min)() : (std::numeric_limits<long>::max)();
^
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
^
/usr/local/include/boost/mp11/list.hpp:45:19: note: 'mp11::mp_size' declared here
template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
^
In file included from boost_gmp.cpp:2:
/usr/local/include/boost/multiprecision/gmp.hpp:1668:17: error: no member named '_mp_size' in '__mpz_struct'
*result = mpz_sgn(val.data()) < 0 ? (std::numeric_limits<long>::min)() : (std::numeric_limits<long>::max)();
^~~~~~~~~~~~~~~~~~~
/usr/local/include/gmp.h:2238:26: note: expanded from macro 'mpz_sgn'
#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
~~~ ^
18 errors generated.
删除#include <boost/log/sinks/text_ostream_backend.hpp>
可解决此问题。更改包含的顺序也可以解决此问题。这是怎么回事?
原来是一个Clang解析器错误。
相关文章:
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 如何防止 c++ 在从浮点型转换为双精度型(不适用于 IO)时添加额外的小数?
- 正在将csv文件读取为双精度矢量
- 如何理解将半精度指针转换为无符号长指针和相关的内存对齐
- 我可以信任表示整数的浮点或双精度来保持精度吗
- 如何在C++中的同一函数中使用字符串和双精度
- 特征::矩阵<双精度,1,3> 结构类型函数中的返回类型函数
- 当使用比格式支持的精度更高的精度来显示数字时,会写出什么数据
- 如何计算具有指定类型的表达式的相对精度和绝对精度
- 如何打印boost多精度128位无符号整数
- 检查是否以特定精度给出双精度
- 转换函数,将 std::数组的双精度作为参数或双精度作为参数单独转换
- 为什么提升日志中断会提升 GMP 多精度?
- 如何在gmp库中使用精度
- 在 gmp 任意精度上生成正态分布
- GMP 浮动值 - 以 10 为基数以给定精度打印它们
- GMP(GNU 多重精度):"mpz_mod"函数错误
- 具有GMP的任意精度运算
- 对于任意精度,是否有公认的GMP替代品
- GMP mpf_class精度低于预期