/ C++

Freestanding C++: What does it mean?

A freestanding implementation of C++ is an implementation that can potentially have all of the features, but not the library or tools to support development in it.

Historically, the following headers are available:

#include <cstddef>
#include <limits>
#include <new>
#include <typeinfo>
#include <exception>
#include <cstdarg>
#include <cstdlib> // See note

<cstdlib> is in this context only required to implement std::abort, std::exit, std::atexit, std::quick_exit and std::at_quick_exit. I would advise not to rely on them depending on the platform you are programming for since they may not work properly if you also were to supply a linker script for example.

In C++11, the support for the following headers was added:

#include <cfloat>
#include <climits>
#include <cstdint>
#include <initializer_list>
#include <type_traits>
#include <atomic>
#include <ciso646> // removed in C++20
#include <cstdalign> // removed in C++20
#include <cstdbool> // removed in C++20

In C++20 were finally added:

#include <version>
#include <source_location>
#include <compare>
#include <coroutine>
#include <concepts>
#include <bit>

Please take note that while operator new() may be declared, it is not necessarily defined.

The opposite of a freestanding implementation of C++ is a hosted implementation. A hosted implementation is relying on an operating system to provide a filesystem, inter-process communication and resource management; on the opposite, a freestanding implementation must provide all of the tools to create those, potentially depending on some externally written assembly code parts to handle specific features.

Conclusion

I invite you to check the information at https://nekoit.xyz/, join us on Discord or Telegram, or follow me on Mastodon [email protected] to receive notifications of my followup posts.

If you like my content and want more, please donate. If everyone that finds my content useful paid $1 every week, I would be able to produce content for 1 week a month without relying on other sources of income for that week.

Freestanding C++: What does it mean?
Share this