[cpp] Using c++20 on FreeBSD
clang
c++20 language features are supported by clang compiler itself, how to enable it:
clang++ -std=c++20 prog.cpp -o prog
The c++20 library features are not provided by default installation. This is how to make c++20 library features work:
Install FreeBSD release src (current src also good):
gitup release
Copy libc++ headers from src:
cd /usr/include/c++ mv v1 v1.old cp -r /usr/src/contrib/llvm-project/libcxx/include ./v1
c++20 is completely enabled now.
WARNING: When you upgrade your FreeBSD operating system next time, you should remove your user custom copy:
cd /usr/include/c++ mv v1 v1.old2 cd freebsd-update upgrade -r XX.Y-release
Another way is to download clang+llvm from llvm project home (at least llvm 12.0):
https://releases.llvm.org/download.html
gcc
Install gcc11-devel
pkg install gcc11-devel
Using c++20 with gcc11-devel
g++11 -std=c++20 prog.cpp -o prog
Comments
Display comments as Linear | Threaded