Ch20.3: Watch: Freestanding C++ — Past, Present, and Future
The History Behind the Problem
This chapter has been about what freestanding C++ cannot do and why. This talk is the history: how the freestanding subset was specified, why its header list stayed unchanged for two decades while the language grew, how the C++23 work finally shipped a usable list, and where the remaining holes came from. It is by Ben Saks, it is from CppCon 2019, and it is the best one-hour account of the subject.
The Talk
What to listen for, in the order the talk raises it:
- What "freestanding" was supposed to mean. The intent was a C++ you could use for a program with no OS; what the standard delivered was a list of headers that implied one.
-
Why the language did not shrink. The grammar kept exceptions, RTTI and
neweven where the runtime could not exist (20.1). - The scoring of what is missing. The talk enumerates the headers and explains which ones can be made freestanding and which cannot.
-
Why containers will never make it.
vector's interface is a heap and an exception; no wording change fixes that (20.1).
After the Video
Come back with the questions the talk leaves open, because the previous pages answer them with the mechanisms a 2019 talk could not assume:
-
20.1 — what a legacy
throwactually needs from the linker, and why you cannot supply it. -
20.2 — the error handling that does
work freestanding: one data symbol, no unwinder, and
[domain](code)instead of a message table. - 20.2 — a program whose allocator and device are type parameters, which is what "freestanding library" should mean and almost never does.
The next chapter, 21, is about the other place C++'s hosted assumptions cost you: the desktop, where the choice is not between a kernel and a standard library but between a GUI toolkit and a web page.