Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost/math/constants/constants.hpp:297:3: error: unable to find numeric literal operator ‘operator""Q’ #272

Closed
zengletian1491 opened this issue Nov 20, 2019 · 14 comments

Comments

@zengletian1491
Copy link

Errors occurred when I compile other projects, and the errors were listed in the following:

/usr/local/include/boost/math/constants/constants.hpp:296:3: note: use -std=gnu++11 or -fext-numeric-literals to enable more built-in suffixes
/usr/local/include/boost/math/constants/constants.hpp: In static member function ‘static constexpr T boost::math::constants::detail::constant_root_half_pi::get(const mpl_::int_<5>&)’:
/usr/local/include/boost/math/constants/constants.hpp:297:3: error: unable to find numeric literal operator ‘operator""Q’
BOOST_DEFINE_MATH_CONSTANT(root_half_pi, 1.253314137315500251207882642405522626e+00, "1.2533141373155002512078826424055226265034933703049691583149617881711468273039209874732
^

I did not know how to solve this problem. Please give me some suggestions if you have. Thanks very much!

@mclow mclow transferred this issue from boostorg/boost Nov 21, 2019
@NAThompson
Copy link
Collaborator

@zengletian1491 : What compiler and what OS are you using?

@pabristow
Copy link
Contributor

If you are using GCC, -std=gnu++11 or -fext-numeric-literals are compiler options that you must add.

Otherwise we need details on your platform chip type and compiler version. and what includes you have to help further.

@jzmaddock
Copy link
Collaborator

There is a mis-configuration in Boost.Config somewhere that it believes __float128 is supported when apparently it is not.

My guess is that you're using a compiler that is pretending to be GCC, but isn't. More details please!

In any case defining BOOST_MATH_DISABLE_FLOAT128 will fix the issue.

@jzmaddock
Copy link
Collaborator

compiler: cmake
OS: Ubuntu 16.04.6 LTS

Ummm, cmake is not a compiler, we need the actual compiler being invoked by cmake (looks like it might be gcc but we can't be sure), PLUS the command line it is invoked with, otherwise there's no way to reproduce.

@zengletian1491
Copy link
Author

zengletian1491 commented Nov 22, 2019

System-Product-Name:~/SoftwareExtractPackages$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial

System-Product-Name:/SoftwareExtractPackages$ uname -a
System-Product-Name 4.15.0-70-generic #79
16.04.1-Ubuntu SMP Tue Nov 12 14:01:10 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

System-Product-Name:~/Work/rtabmap/build$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done

Thanks very much!

jzmaddock added a commit to boostorg/config that referenced this issue Nov 22, 2019
@jzmaddock
Copy link
Collaborator

Nope, still missing something.... I updated the Boost.Config CI tests to check gcc-5 in gnu mode and all the tests are still passing (and verify that __float128 support is turned on): https://travis-ci.org/boostorg/config/jobs/615513039

So I think we need the full g++ command line.

@zengletian1491
Copy link
Author

I'm really sorry for my late reply. Well, after "cmake .." is typed, the results are shown in the attached file "afer cmake.docx";
after "make" is typed, the results are shown in the attached file named "after make.docx". Thanks very much for your help!
after cmake.docx
after make.docx

@jzmaddock
Copy link
Collaborator

Still not seeing a compiler command line in there, can you post the generated Makefile as well?

@zengletian1491
Copy link
Author

The Makefile is in the attached file!Thank you!
Makefile.txt

@jzmaddock
Copy link
Collaborator

Ah... that's just the top level Makefile and the actual commands are apparently split between multiple sub-files :(

After a bit of googling, it looks like running:

make VERBOSE=1

should hopefully spit out the actual commands being used.

@zengletian1491
Copy link
Author

This is the “build”file obtained with "cmake.." and "make VERBOSE=1"
build.zip

@jzmaddock
Copy link
Collaborator

Reduced test case (with gcc-5.x only) is:

g++ -I../../.. -std=c++11 -std=gnu++11 compile_test/constants_incl_test.cpp

Everything is fine with either one or the other -std options, it's mixing the 2 that confuses things.

@jzmaddock
Copy link
Collaborator

OK, more investigation reveals that this is an issue for gcc-5 and 6, but was fixed for gcc-7 and later.

So the workarounds are:

  1. Don't mix -std=c++11 and -std=gnu++11 on the same command line. This might require fixing CMake though ;( Or,
  2. As the error message suggests, add -fext-numeric-literals to the compiler flags. Or
  3. Add -DBOOST_MATH_DISABLE_FLOAT128 to the compiler flags. Or
  4. Add #define BOOST_MATH_DISABLE_FLOAT128 to boost/math/tools/user.hpp`.

At present I simply don't see any way to fix this at our end because the list of predefined macros gcc sets is identical between -std=c++11 -std=gnu++11 and just -std=gnu++11. Which of course they should be since the second -std= option supersedes the first. Unfortunately mixing the 2 options like this seems to cause gcc to get into an inconsistent internal state, with the -std=gnu++11 not being fully honoured.

I'm inclined to close this as "not our problem", but perhaps I'll leave open for future Googlers to find... or in hopes of a bright idea from someone. In any case, I doubt there will be any more patches/releases of gcc-5 at this stage.

@zengletian1491
Copy link
Author

Thanks very much for your help!@jzmaddock

@NAThompson NAThompson changed the title /usr/local/include/boost/math/constants/constants.hpp:297:3: error: unable to find numeric literal operator ‘operator""Q’ BOOST_DEFINE_MATH_CONSTANT(root_half_pi, 1.253314137315500251207882642405522626e+00, "1.2533141373155002512078826424055226265034933703049691583149617881711468273039209874732 ^ boost/math/constants/constants.hpp:297:3: error: unable to find numeric literal operator ‘operator""Q’ Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants