Trouble compiling with float128 data type
Hi, I'm having trouble compiling code that contains float128 data type. I'm using MacOS Big Sur 11.4. Compiler: gcc version 11.1.0 (Homebrew GCC 11.1.0_1) I have no other problems with Boost, the only problem is when I use float128. Please note that I have no problem compiling using libquadmath without using Boost using the __float128 data type. I use Visual Studio Code: "tasks": [ { "label": "Build with g++ 11", "type": "shell", "command": "g++-11", "args": [ "-g", "-I/usr/local/Cellar/boost/1.76.0/include/", "-I/usr/local/include/", "-L/usr/local/Cellar/boost/1.76.0/lib/", "-L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/", "-L/usr/local/Cellar/gmp/6.2.1/lib/", "-L/usr/local/Cellar/mpfr/4.1.0/lib/", "-lmpfr", "-lgmp", "-lquadmath", "-lboost_system", "-lboost_filesystem", "-std=c++20", "'-fext-numeric-literals'", "float128_example.cpp", "-o", "main" ], "group": { "kind": "build", "isDefault": true } }, There are other libraries (gmp, mpfr, ...) because I have compiled several examples taken from the Boost site (such as, for example, automatic_differentation.cpp, GMP_example.cpp, MPFR_example.cpp etc.) and they all compile and run correctly. I tried to compile the following example: #include <boost/cstdfloat.hpp> // For float_64_t, float128_t. Must be first include! //#include <boost/config.hpp> #include <boost/multiprecision/float128.hpp> #include <boost/math/special_functions.hpp> // For gamma function. #include <boost/math/constants/constants.hpp> // For constants pi, e ... #include <typeinfo> // #include <cmath> // for pow function. int main() { try { //[float128_example_3 // Always use try'n'catch blocks to ensure any error messages are displayed. //`Ensure that all possibly significant digits (17) including trailing zeros are shown. std::cout.precision(std::numeric_limits<boost::float64_t>::max_digits10); std::cout.setf(std::ios::showpoint); // Show all significant trailing zeros. //] [/ float128_example_3] #ifdef BOOST_FLOAT128_C std::cout << "Floating-point type boost::float128_t is available." << std::endl; std::cout << " std::numeric_limits<boost::float128_t>::digits10 == " << std::numeric_limits<boost::float128_t>::digits10 << std::endl; std::cout << " std::numeric_limits<boost::float128_t>::max_digits10 == " << std::numeric_limits<boost::float128_t>::max_digits10 << std::endl; #else std::cout << "Floating-point type boost::float128_t is NOT available." << std::endl; #endif show_versions(""); using boost::multiprecision::float128; // Wraps, for example, __float128 or _Quad. // or //using namespace boost::multiprecision; std::cout.precision(std::numeric_limits<float128>::max_digits10); // Show all potentially meaningful digits. std::cout.setf(std::ios::showpoint); // Show all significant trailing zeros. // float128 pi0 = boost::math::constants::pi(); // Compile fails - need to specify a type for the constant! float128 pi1 = boost::math::constants::pi<float128>(); // Returns a constant of type float128. std::cout << sqrt(pi1) << std::endl; // 1.77245385090551602729816748334114514 float128 pi2 = boost::math::constants::pi<__float128>(); // Constant of type __float128 gets converted to float128 on the assignment. std::cout << sqrt(pi2) << std::endl; // 1.77245385090551602729816748334114514 // DIY decimal digit literal constant, with suffix Q. float128 pi3 = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348Q; std::cout << sqrt(pi3) << std::endl; // 1.77245385090551602729816748334114514 // Compare to ready-rolled sqrt(pi) constant from Boost.Math: std::cout << boost::math::constants::root_pi<float128>() << std::endl; // 1.77245385090551602729816748334114514 // DIY decimal digit literal constant, without suffix Q, suffering seventeen silent digits loss of precision! float128 pi4 = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348; std::cout << sqrt(pi4) << std::endl; // 1.77245385090551599275151910313924857 … … what i get is:
Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem -std=c++20 '-fext-numeric-literals' float128_example.cpp -o main <
float128_example.cpp: In function 'int main()': float128_example.cpp:143:56: error: conversion from 'boost::math::constants::detail::constant_return<__float128, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >::type' {aka '__float128'} to non-scalar type 'boost::multiprecision::float128' {aka 'boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>'} requested 143 | float128 pi2 = boost::math::constants::pi<__float128>(); // Constant of type __float128 gets converted to float128 on the assignment. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ float128_example.cpp:147:18: error: conversion from '__float128' to non-scalar type 'boost::multiprecision::float128' {aka 'boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>'} requested 147 | float128 pi3 = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348Q; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ float128_example.cpp:160:37: error: conversion from '__float128' to non-scalar type 'const float128' {aka 'const boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>'} requested 160 | constexpr float128 pi_constexpr = 3.1415926535897932384626433832795028841971693993751058Q; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/local/Cellar/boost/1.76.0/include/boost/math/special_functions/gamma.hpp:23, from /usr/local/Cellar/boost/1.76.0/include/boost/math/special_functions/detail/bessel_jy.hpp:14, from /usr/local/Cellar/boost/1.76.0/include/boost/math/special_functions/bessel.hpp:20, from /usr/local/Cellar/boost/1.76.0/include/boost/math/special_functions/airy.hpp:12, from /usr/local/Cellar/boost/1.76.0/include/boost/math/special_functions.hpp:15, from float128_example.cpp:22: float128_example.cpp:172:83: in 'constexpr' expansion of 'boost::math::constants::root_pi<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off> >()' /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:237:54: error: 'constexpr typename boost::math::constants::detail::constant_return<Real, Policy>::type boost::math::constants::root_pi() [with T = boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>; Policy = boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>; typename boost::math::constants::detail::constant_return<Real, Policy>::type = const boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>&]' called in a constant expression 237 | { return name<T, boost::math::policies::policy<> >(); }\ | ^ /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:269:3: note: in expansion of macro 'BOOST_DEFINE_MATH_CONSTANT' 269 | BOOST_DEFINE_MATH_CONSTANT(root_pi, 1.772453850905516027298167483341145182e+00, "1.77245385090551602729816748334114518279754945612238712821380778985291128459103218137495065673854466541622682362e+00") | ^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:269:30: note: 'constexpr typename boost::math::constants::detail::constant_return<Real, Policy>::type boost::math::constants::root_pi() [with T = boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>; Policy = boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>; typename boost::math::constants::detail::constant_return<Real, Policy>::type = const boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>&]' is not usable as a 'constexpr' function because: 269 | BOOST_DEFINE_MATH_CONSTANT(root_pi, 1.772453850905516027298167483341145182e+00, "1.77245385090551602729816748334114518279754945612238712821380778985291128459103218137495065673854466541622682362e+00") | ^~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:234:116: note: in definition of macro 'BOOST_DEFINE_MATH_CONSTANT' 234 | template <typename T, typename Policy> inline BOOST_CONSTEXPR typename detail::constant_return<T, Policy>::type name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(Policy)) BOOST_MATH_NOEXCEPT(T)\ | ^~~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:235:57: error: call to non-'constexpr' function 'static const T& boost::math::constants::detail::constant_root_pi<T>::get(const std::integral_constant<int, 4>&) [with T = boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>]' 235 | { return detail:: BOOST_JOIN(constant_, name)<T>::get(typename construction_traits<T, Policy>::type()); }\ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:269:3: note: in expansion of macro 'BOOST_DEFINE_MATH_CONSTANT' 269 | BOOST_DEFINE_MATH_CONSTANT(root_pi, 1.772453850905516027298167483341145182e+00, "1.77245385090551602729816748334114518279754945612238712821380778985291128459103218137495065673854466541622682362e+00") | ^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:207:27: note: 'static const T& boost::math::constants::detail::constant_root_pi<T>::get(const std::integral_constant<int, 4>&) [with T = boost::multiprecision::number<boost::multiprecision::backends::float128_backend, boost::multiprecision::et_off>]' declared here 207 | static inline const T& get(const std::integral_constant<int, construct_from_string>&)\ | ^~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:207:27: note: in definition of macro 'BOOST_DEFINE_MATH_CONSTANT' 207 | static inline const T& get(const std::integral_constant<int, construct_from_string>&)\ | ^~~ float128_example.cpp:186:20: error: call of overloaded 'exp(__float128)' is ambiguous 186 | float128 e1 = exp(1.Q); // Note argument to exp is type float128. | ~~~^~~~~ In file included from /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:45, from /usr/local/Cellar/boost/1.76.0/include/boost/config/no_tr1/cmath.hpp:21, from /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/config.hpp:19, from /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:18, from /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, from float128_example.cpp:19: /usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0/include-fixed/math.h:376:15: note: candidate: 'double exp(double)' 376 | extern double exp(double); | ^~~ In file included from /usr/local/Cellar/boost/1.76.0/include/boost/config/no_tr1/cmath.hpp:21, from /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/config.hpp:19, from /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:18, from /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, from float128_example.cpp:19: /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:226:3: note: candidate: 'constexpr long double std::exp(long double)' 226 | exp(long double __x) | ^~~ /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:222:3: note: candidate: 'constexpr float std::exp(float)' 222 | exp(float __x) | ^~~ In file included from /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:17, from /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, from float128_example.cpp:19: /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/precision.hpp: In instantiation of 'constexpr int boost::math::tools::digits() [with T = __float128]': /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:259:3: required from 'static const T& boost::math::constants::detail::constant_pi<T>::get_from_variable_precision() [with T = __float128]' /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:259:3: required from 'static T boost::math::constants::detail::constant_pi<T>::get(const std::integral_constant<int, 0>&) [with T = __float128]' /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:259:3: required from 'constexpr typename boost::math::constants::detail::constant_return<Real, Policy>::type boost::math::constants::pi() [with T = __float128; Policy = boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>; typename boost::math::constants::detail::constant_return<Real, Policy>::type = __float128]' /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:259:3: required from 'constexpr typename boost::math::constants::detail::constant_return<T>::type boost::math::constants::pi() [with T = __float128; typename boost::math::constants::detail::constant_return<T>::type = __float128]' float128_example.cpp:143:56: required from here /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/precision.hpp:44:51: error: static assertion failed: ::std::numeric_limits<T>::is_specialized 44 | BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized); | ^~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/static_assert.hpp:70:55: note: in definition of macro 'BOOST_STATIC_ASSERT' 70 | # define BOOST_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__) | ^~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/precision.hpp:44:51: note: 'std::__numeric_limits_base::is_specialized' evaluates to false 44 | BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized); | ^~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/static_assert.hpp:70:55: note: in definition of macro 'BOOST_STATIC_ASSERT' 70 | # define BOOST_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__) | ^~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/precision.hpp:45:62: error: static assertion failed: ::std::numeric_limits<T>::radix == 2 || ::std::numeric_limits<T>::radix == 10 45 | BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::radix == 2 || ::std::numeric_limits<T>::radix == 10); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/static_assert.hpp:70:55: note: in definition of macro 'BOOST_STATIC_ASSERT' 70 | # define BOOST_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__) | ^~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/precision.hpp:45:62: note: '((((int)std::__numeric_limits_base::radix) == 2) || (((int)std::__numeric_limits_base::radix) == 10))' evaluates to false 45 | BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::radix == 2 || ::std::numeric_limits<T>::radix == 10); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/static_assert.hpp:70:55: note: in definition of macro 'BOOST_STATIC_ASSERT' 70 | # define BOOST_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__) | ^~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/lexical_cast/detail/converter_lexical.hpp: In instantiation of 'struct boost::detail::deduce_target_char_impl<boost::detail::deduce_character_type_later<__float128> >': /usr/local/Cellar/boost/1.76.0/include/boost/lexical_cast/detail/converter_lexical.hpp:270:89: required from 'struct boost::detail::deduce_target_char<__float128>' /usr/local/Cellar/boost/1.76.0/include/boost/lexical_cast/detail/converter_lexical.hpp:407:92: required from 'struct boost::detail::lexical_cast_stream_traits<const char*, __float128>' /usr/local/Cellar/boost/1.76.0/include/boost/lexical_cast/detail/converter_lexical.hpp:468:15: required from 'struct boost::detail::lexical_converter_impl<__float128, const char*>' /usr/local/Cellar/boost/1.76.0/include/boost/lexical_cast/try_lexical_convert.hpp:201:44: required from 'bool boost::conversion::detail::try_lexical_convert(const Source&, Target&) [with Target = __float128; Source = const char*]' /usr/local/Cellar/boost/1.76.0/include/boost/lexical_cast.hpp:41:60: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ] /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/convert_from_string.hpp:43:39: required from 'constexpr typename boost::math::tools::convert_from_string_result<T>::type boost::math::tools::convert_from_string(const char*) [with Real = __float128; typename boost::math::tools::convert_from_string_result<T>::type = __float128]' /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:259:3: required from 'static const T& boost::math::constants::detail::constant_pi<T>::get_from_variable_precision() [with T = __float128]' /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:259:3: required from 'static T boost::math::constants::detail::constant_pi<T>::get(const std::integral_constant<int, 0>&) [with T = __float128]' /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:259:3: required from 'constexpr typename boost::math::constants::detail::constant_return<Real, Policy>::type boost::math::constants::pi() [with T = __float128; Policy = boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>; typename boost::math::constants::detail::constant_return<Real, Policy>::type = __float128]' /usr/local/Cellar/boost/1.76.0/include/boost/math/constants/constants.hpp:259:3: required from 'constexpr typename boost::math::constants::detail::constant_return<T>::type boost::math::constants::pi() [with T = __float128; typename boost::math::constants::detail::constant_return<T>::type = __float128]' float128_example.cpp:143:56: required from here /usr/local/Cellar/boost/1.76.0/include/boost/lexical_cast/detail/converter_lexical.hpp:243:54: error: static assertion failed: Target type is neither std::istream`able nor std::wistream`able 243 | BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_right_shift<std::basic_istream<wchar_t>, T >::value), | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/static_assert.hpp:31:59: note: in definition of macro 'BOOST_STATIC_ASSERT_MSG' 31 | # define BOOST_STATIC_ASSERT_MSG( ... ) static_assert(__VA_ARGS__) | ^~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/lexical_cast/detail/converter_lexical.hpp:243:54: note: '(((bool)boost::integral_constant<bool, false>::value) || ((bool)boost::integral_constant<bool, false>::value))' evaluates to false 243 | BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_right_shift<std::basic_istream<wchar_t>, T >::value), | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/Cellar/boost/1.76.0/include/boost/static_assert.hpp:31:59: note: in definition of macro 'BOOST_STATIC_ASSERT_MSG' 31 | # define BOOST_STATIC_ASSERT_MSG( ... ) static_assert(__VA_ARGS__) | ^~~~~~~~~~~ The terminal process "zsh '-c', 'g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem -std=c++20 '-fext-numeric-literals' float128_example.cpp -o main'" terminated with exit code: 1. Terminal will be reused by tasks, press any key to close it. Thanks Stefano Gragnani Inviato da iPad
On 20/07/2021 18:44, Stefano Gragnani via Boost-users wrote:
Hi,
I'm having trouble compiling code that contains float128 data type. I'm using MacOS Big Sur 11.4. Compiler: gcc version 11.1.0 (Homebrew GCC 11.1.0_1)
I have no other problems with Boost, the only problem is when I use float128.
Please note that I have no problem compiling using libquadmath without using Boost using the __float128 data type.
I use Visual Studio Code:
You can manually fix this by defining BOOST_HAS_FLOAT128 on the command line. However, you may still hit other errors as __float128 and quadmath.h aren't really fully supported in ISO C++ mode. The correct fix is to use -std=gnu++20, and then GNU extensions including __float128 are turned on. HTH, John. -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
ok things are better but i still get errors:
Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' float128_example.cpp -o main <
float128_example.cpp: In function 'int main()': float128_example.cpp:186:20: error: call of overloaded 'exp(__float128)' is ambiguous 186 | float128 e1 = exp(1.Q); // Note argument to exp is type float128. | ~~~^~~~~ In file included from /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:45, from /usr/local/Cellar/boost/1.76.0/include/boost/config/no_tr1/cmath.hpp:21, from /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/config.hpp:19, from /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:18, from /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, from float128_example.cpp:19: /usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0/include-fixed/math.h:376:15: note: candidate: 'double exp(double)' 376 | extern double exp(double); | ^~~ In file included from /usr/local/Cellar/boost/1.76.0/include/boost/config/no_tr1/cmath.hpp:21, from /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/config.hpp:19, from /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:18, from /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, from float128_example.cpp:19: /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:226:3: note: candidate: 'constexpr long double std::exp(long double)' 226 | exp(long double __x) | ^~~ /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:222:3: note: candidate: 'constexpr float std::exp(float)' 222 | exp(float __x) | ^~~ The terminal process "zsh '-c', 'g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' float128_example.cpp -o main'" terminated with exit code: 1. Compiling the following example: #include <iomanip> #include <iostream> #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> #include <boost/multiprecision/float128.hpp> #include <boost/math/special_functions/gamma.hpp> #include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/math/constants/constants.hpp> int main() { using boost::multiprecision::float128; float128 b = 2; std::cout << std::numeric_limits<float128>::digits << std::endl; std::cout << std::numeric_limits<float128>::digits10 << std::endl; std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << log(b) << std::endl; constexpr float128 pi = 3.1415926535897932384626433832795028841971693993751058Q; return 0; } I get:
Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' fs_main.cpp -o main <
Undefined symbols for architecture x86_64: "__Z17quadmath_snprintfPcmPKcz", referenced from: __ZNK5boost14multiprecision8backends16float128_backend3strB5cxx11ElSt13_Ios_Fmtflags in ccGxvsSR.o "__Z4logqg", referenced from: __ZN5boost14multiprecision8backends8eval_logERNS1_16float128_backendERKS2_ in ccGxvsSR.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status The terminal process "zsh '-c', 'g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' fs_main.cpp -o main'" terminated with exit code: 1. Note that if I compile the following example without using Boost I have no linking errors with quadmath: #include <quadmath.h> #include <iostream> #include <stdlib.h> #include <stdio.h> int print(const char *label, __float128 r) { int prec = 20; int width = 46; char buf[128]; int n = quadmath_snprintf(buf, sizeof buf, "%+-#*.36Qe", width, r); printf ("%s: %s\n", label, buf); return 0; } int main () { __float128 x = 3.14159265358979323846264338327950288q; print("value", x); print("log", logq(x)); print("log10", log10q(x)); print("cos", cosq(x)); print("sin", sinq(x)); print("sqrt", sqrtq(x)); } Executing task: ./es1.out < value: +3.141592653589793238462643383279502797e+00 log: +1.144729885849400174143427351353058656e+00 log10: +4.971498726941338543512682882908988723e-01 cos: -1.000000000000000000000000000000000000e+00 sin: +8.671810130123781024797044026043352254e-35 sqrt: +1.772453850905516027298167483341145140e+00 The settings are: "tasks": [ { "label": "Build with g++ 11", "type": "shell", "command": "g++-11", "args": [ "-g", "-std=gnu++20”, "es1.cpp", "-L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/", "-lquadmath", "-o", "es1.out" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": [] },
Il giorno 21 lug 2021, alle ore 13:08, John Maddock via Boost-users <boost-users@lists.boost.org> ha scritto:
On 20/07/2021 18:44, Stefano Gragnani via Boost-users wrote:
Hi,
I'm having trouble compiling code that contains float128 data type. I'm using MacOS Big Sur 11.4. Compiler: gcc version 11.1.0 (Homebrew GCC 11.1.0_1)
I have no other problems with Boost, the only problem is when I use float128.
Please note that I have no problem compiling using libquadmath without using Boost using the __float128 data type.
I use Visual Studio Code:
You can manually fix this by defining BOOST_HAS_FLOAT128 on the command line. However, you may still hit other errors as __float128 and quadmath.h aren't really fully supported in ISO C++ mode. The correct fix is to use -std=gnu++20, and then GNU extensions including __float128 are turned on.
HTH, John.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On 21/07/2021 16:56, Stefano Gragnani via Boost-users wrote:
ok things are better but i still get errors:
Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' float128_example.cpp -o main <
float128_example.cpp: In function 'int main()': float128_example.cpp:186:20: error: call of overloaded 'exp(__float128)' is ambiguous 186 | float128 e1 = exp(1.Q); // Note argument to exp is type float128. | ~~~^~~~~
The compiler is quite correct: there are no std lib functions for the built in type __float128, there are however for boost::multiprecision::float128 which is the type you should be using throughout. -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
If I comment: // float128 e1 = exp(1.Q); // Note argument to exp is type float128. // std::cout << e1 << std::endl; // 2.71828182845904523536028747135266231 the example compiles correctly. Floating-point type boost::float128_t is available. std::numeric_limits<boost::float128_t>::digits10 == 33 std::numeric_limits<boost::float128_t>::max_digits10 == 36 Platform: Mac OS Compiler: GNU C++ version 11.1.0 STL : GNU libstdc++ version 20210427 Boost : 1.76.0 GCC 11.1.0 1.77245385090551602729816748334114514 1.77245385090551602729816748334114514 1.77245385090551602729816748334114514 1.77245385090551602729816748334114514 1.77245385090551599275151910313924857 3.14159265358979323846264338327950280 1.77245385090551602729816748334114514 2.71828182845904523536028747135266231 2.71828182845904509079559829842764884 2.71828182845904509079559829842764884 2.71828174591064453125000000000000000 2.71828182845904523536028747135266231 2.71828182845904523536028747135266231 2.71828182845904523536028747135266231 N5boost14multiprecision6numberINS0_8backends16float128_backendELNS0_26expression_template_optionE0EEE N5boost14multiprecision6numberINS0_8backends16float128_backendELNS0_26expression_template_optionE0EEE N5boost14multiprecision6numberINS0_8backends16float128_backendELNS0_26expression_template_optionE0EEE
Il giorno 21 lug 2021, alle ore 18:48, John Maddock via Boost-users <boost-users@lists.boost.org> ha scritto:
The compiler is quite correct: there are no std lib functions for the built in type __float128, there are however for boost::multiprecision::float128 which is the type you should be using throughout.
further clarification if possible: why the 2 lines that don't compile: // float128 e1 = exp(1.Q); // Note argument to exp is type float128. // std::cout << e1 << std::endl; // 2.71828182845904523536028747135266231 if i put them in the following code compile regularly? #include <iomanip> #include <iostream> #include <boost/cstdfloat.hpp> // For float_64_t, float128_t. Must be first include! #include <boost/multiprecision/float128.hpp> #include <boost/math/special_functions.hpp> // For gamma function. #include <boost/math/constants/constants.hpp> // For constants pi, e ... #include <typeinfo> #include <cmath> // for pow function. using namespace std; int main() { using boost::multiprecision::float128; // Operations at 128-bit precision and full numeric_limits support: float128 b = 2; // There are 113-bits of precision: std::cout << std::numeric_limits<float128>::digits << std::endl; // Or 34 decimal places: std::cout << std::numeric_limits<float128>::digits10 << std::endl; // We can use any C++ std lib function, lets print all the digits as well: std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << log(b) << std::endl; // print log(2) = 0.693147180559945309417232121458176575 // We can also use any function from Boost.Math: std::cout << boost::math::tgamma(b) << std::endl; // And since we have an extended exponent range we can generate some really large // numbers here (4.02387260077093773543702433923004111e+2564): std::cout << boost::math::tgamma(float128(1000)) << std::endl; // // We can declare constants using GCC or Intel's native types, and the Q suffix, // these can be declared constexpr if required: constexpr float128 pi = 3.1415926535897932384626433832795028841971693993751058Q; float128 e1 = exp(1.Q); // Note argument to exp is type float128. std::cout << e1 << std::endl; // 2.71828182845904523536028747135266231 cout << "pi = " << pi << endl; cout << "e1 = " << e1 << endl; return 0; }
Executing task: ./main <
113 33 0.693147180559945309417232121458176575 1 4.02387260077093773543702433923004111e+2564 2.71828182845904523536028747135266231 pi = 3.1415926535897932384626433832795028 e1 = 2.71828182845904523536028747135266231 Thanks
Il giorno 21 lug 2021, alle ore 19:14, Stefano Gragnani <stefano.gragnani@gmail.com> ha scritto:
// float128 e1 = exp(1.Q); // Note argument to exp is type float128. // std::cout << e1 << std::endl; // 2.71828182845904523536028747135266231
On 21/07/2021 19:07, Stefano Gragnani via Boost-users wrote:
further clarification if possible:
why the 2 lines that don't compile:
// float128 e1 = exp(1.Q); // Note argument to exp is type float128. // std::cout << e1 << std::endl; // 2.71828182845904523536028747135266231
if i put them in the following code compile regularly?
You're mixing up 2 different things: * If you want to use __float128 "as if" it were no different to float/double etc, then include boost/math/cstdfloat.hpp * If you want a 128-bit floating point type which hides the underlying implementation then use boost/multiprecision/float128.hpp. Note that these are completely different approaches to the same problem, and are completely different types. Also note that strictly speaking, boost/math/cstdfloat.hpp is NOT C++ conformant, as it adds function overloads directly to namespace std. -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
thanks now everything begins to be more understandable Inviato da iPad
Il giorno 21 lug 2021, alle ore 23:40, John Maddock via Boost-users <boost-users@lists.boost.org> ha scritto:
On 21/07/2021 19:07, Stefano Gragnani via Boost-users wrote:
further clarification if possible:
why the 2 lines that don't compile:
// float128 e1 = exp(1.Q); // Note argument to exp is type float128. // std::cout << e1 << std::endl; // 2.71828182845904523536028747135266231
if i put them in the following code compile regularly?
You're mixing up 2 different things:
* If you want to use __float128 "as if" it were no different to float/double etc, then include boost/math/cstdfloat.hpp
* If you want a 128-bit floating point type which hides the underlying implementation then use boost/multiprecision/float128.hpp.
Note that these are completely different approaches to the same problem, and are completely different types.
Also note that strictly speaking, boost/math/cstdfloat.hpp is NOT C++ conformant, as it adds function overloads directly to namespace std.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
I solved for the other example, I must add: #include <boost/cstdfloat.hpp> // For float_64_t, float128_t. Must be first include! Thank you so much
Il giorno 21 lug 2021, alle ore 18:48, John Maddock via Boost-users <boost-users@lists.boost.org> ha scritto:
On 21/07/2021 16:56, Stefano Gragnani via Boost-users wrote:
ok things are better but i still get errors:
Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' float128_example.cpp -o main <
float128_example.cpp: In function 'int main()': float128_example.cpp:186:20: error: call of overloaded 'exp(__float128)' is ambiguous 186 | float128 e1 = exp(1.Q); // Note argument to exp is type float128. | ~~~^~~~~
The compiler is quite correct: there are no std lib functions for the built in type __float128, there are however for boost::multiprecision::float128 which is the type you should be using throughout.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
so how should I complie your example? and for the following code:
#include <iomanip> #include <iostream> #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> #include <boost/multiprecision/float128.hpp> #include <boost/math/special_functions/gamma.hpp> #include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/math/constants/constants.hpp>
int main() { using boost::multiprecision::float128;
float128 b = 2; std::cout << std::numeric_limits<float128>::digits << std::endl; std::cout << std::numeric_limits<float128>::digits10 << std::endl; std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << log(b) << std::endl; constexpr float128 pi = 3.1415926535897932384626433832795028841971693993751058Q; return 0; }
I get:
Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' fs_main.cpp -o main <
Undefined symbols for architecture x86_64: "__Z17quadmath_snprintfPcmPKcz", referenced from: __ZNK5boost14multiprecision8backends16float128_backend3strB5cxx11ElSt13_Ios_Fmtflags in ccGxvsSR.o "__Z4logqg", referenced from: __ZN5boost14multiprecision8backends8eval_logERNS1_16float128_backendERKS2_ in ccGxvsSR.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status The terminal process "zsh '-c', 'g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' fs_main.cpp -o main'" terminated with exit code: 1.
Thanks Stefano Gragnani
Il giorno 21 lug 2021, alle ore 17:56, Stefano Gragnani <stefano.gragnani@gmail.com> ha scritto:
ok things are better but i still get errors:
Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' float128_example.cpp -o main <
float128_example.cpp: In function 'int main()': float128_example.cpp:186:20: error: call of overloaded 'exp(__float128)' is ambiguous 186 | float128 e1 = exp(1.Q); // Note argument to exp is type float128. | ~~~^~~~~ In file included from /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:45, from /usr/local/Cellar/boost/1.76.0/include/boost/config/no_tr1/cmath.hpp:21, from /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/config.hpp:19, from /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:18, from /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, from float128_example.cpp:19: /usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0/include-fixed/math.h:376:15: note: candidate: 'double exp(double)' 376 | extern double exp(double); | ^~~ In file included from /usr/local/Cellar/boost/1.76.0/include/boost/config/no_tr1/cmath.hpp:21, from /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/config.hpp:19, from /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:18, from /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, from float128_example.cpp:19: /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:226:3: note: candidate: 'constexpr long double std::exp(long double)' 226 | exp(long double __x) | ^~~ /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:222:3: note: candidate: 'constexpr float std::exp(float)' 222 | exp(float __x) | ^~~ The terminal process "zsh '-c', 'g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' float128_example.cpp -o main'" terminated with exit code: 1.
Compiling the following example:
#include <iomanip> #include <iostream> #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> #include <boost/multiprecision/float128.hpp> #include <boost/math/special_functions/gamma.hpp> #include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/math/constants/constants.hpp>
int main() { using boost::multiprecision::float128;
float128 b = 2; std::cout << std::numeric_limits<float128>::digits << std::endl; std::cout << std::numeric_limits<float128>::digits10 << std::endl; std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << log(b) << std::endl; constexpr float128 pi = 3.1415926535897932384626433832795028841971693993751058Q; return 0; }
I get:
Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' fs_main.cpp -o main <
Undefined symbols for architecture x86_64: "__Z17quadmath_snprintfPcmPKcz", referenced from: __ZNK5boost14multiprecision8backends16float128_backend3strB5cxx11ElSt13_Ios_Fmtflags in ccGxvsSR.o "__Z4logqg", referenced from: __ZN5boost14multiprecision8backends8eval_logERNS1_16float128_backendERKS2_ in ccGxvsSR.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status The terminal process "zsh '-c', 'g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem '-fext-numeric-literals' fs_main.cpp -o main'" terminated with exit code: 1.
Note that if I compile the following example without using Boost I have no linking errors with quadmath:
#include <quadmath.h> #include <iostream> #include <stdlib.h> #include <stdio.h>
int print(const char *label, __float128 r) { int prec = 20; int width = 46; char buf[128];
int n = quadmath_snprintf(buf, sizeof buf, "%+-#*.36Qe", width, r); printf ("%s: %s\n", label, buf); return 0; }
int main () { __float128 x = 3.14159265358979323846264338327950288q; print("value", x); print("log", logq(x)); print("log10", log10q(x)); print("cos", cosq(x)); print("sin", sinq(x)); print("sqrt", sqrtq(x)); }
Executing task: ./es1.out <
value: +3.141592653589793238462643383279502797e+00 log: +1.144729885849400174143427351353058656e+00 log10: +4.971498726941338543512682882908988723e-01 cos: -1.000000000000000000000000000000000000e+00 sin: +8.671810130123781024797044026043352254e-35 sqrt: +1.772453850905516027298167483341145140e+00
The settings are:
"tasks": [ { "label": "Build with g++ 11", "type": "shell", "command": "g++-11", "args": [ "-g", "-std=gnu++20”, "es1.cpp", "-L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/", "-lquadmath", "-o", "es1.out" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": [] },
Il giorno 21 lug 2021, alle ore 13:08, John Maddock via Boost-users <boost-users@lists.boost.org <mailto:boost-users@lists.boost.org>> ha scritto:
On 20/07/2021 18:44, Stefano Gragnani via Boost-users wrote:
Hi,
I'm having trouble compiling code that contains float128 data type. I'm using MacOS Big Sur 11.4. Compiler: gcc version 11.1.0 (Homebrew GCC 11.1.0_1)
I have no other problems with Boost, the only problem is when I use float128.
Please note that I have no problem compiling using libquadmath without using Boost using the __float128 data type.
I use Visual Studio Code:
You can manually fix this by defining BOOST_HAS_FLOAT128 on the command line. However, you may still hit other errors as __float128 and quadmath.h aren't really fully supported in ISO C++ mode. The correct fix is to use -std=gnu++20, and then GNU extensions including __float128 are turned on.
HTH, John.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus <https://www.avast.com/antivirus>
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
John Maddock
-
Stefano Gragnani