[英]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>
可解決此問題。 更改include的順序也可以解決該問題。 這是怎么回事?
原來是Clang解析器錯誤 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.