I have installed clang-13, but when I try to compile a program that uses C++20 headers, I get missing header errors.
#include <numeric>
#include <numbers> // missing
It seems that CMake uses the system headers (from the old GCC headers shipped with ubuntu). How do I convince it to use the Clang's headers instead?
Numbers header is part of C++20 https://en.cppreference.com/w/cpp/header/numbers
Installing the latest version of g++ fixed the issue for me. For example, g++-11 is the latest version at the moment. To install it on Ubuntu:
Add the toolchain ppa to ensure that the latest version is available:
sudo add-apt-repository --update -y ppa:ubuntu-toolchain-r/test
sudo apt-get update -y
Then install
sudo apt-get -y --fix-broken install gcc-11 g++-11
You can check for the latest version here: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.