Skip to content

[cpp] Using c++20 on FreeBSD


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
freebsd-update upgrade -r XX.Y-release

Another way is to download clang+llvm from llvm project home (at least llvm 12.0):


Install gcc11-devel

pkg install gcc11-devel

Using c++20 with gcc11-devel

g++11 -std=c++20 prog.cpp -o prog





No Trackbacks


Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.

Form options

Submitted comments will be subject to moderation before being displayed.