What are the features that I can use in c++ freestanding environment?
Much of freestanding implementations is implementation defined:
[intro.compliance] ... A freestanding
implementation is one in which execution may take place without the benefit of an operating system, and
has an implementation-defined set of libraries that includes certain language-support libraries
[intro.multithread] ... Under a freestanding implementation, it is implementation-defined whether
a program can have more than one thread of execution.
[basic.start.main] It
is implementation-defined whether a program in a freestanding environment is required to define a main
function. [ Note: In a freestanding environment, start-up and termination is implementation-defined; start-
up contains the execution of constructors for objects of namespace scope with static storage duration;
termination contains the execution of destructors for objects with static storage duration. — end note ]
[using.headers] C ++ headers for freestanding implementations
<ciso646>
<cstddef>
<cfloat>
<limits>
<climits>
<cstdint>
<cstdlib>
<new>
<typeinfo>
<exception>
<initializer_list>
<cstdalign>
<cstdarg>
<cstdbool>
<atomic>
[compliance] The supplied version of the header <cstdlib>
shall declare at least the functions abort, atexit, at_quick_-
exit, exit, and quick_exit (18.5). The other headers listed in this table shall meet the same requirements
as for a hosted implementation.
Note that malloc
/free
are not listed in the required functions of <cstdlib>
.
As far as your linker error is concerned, neither freestanding, nor hosted implementation is required to provide those overloads:
[replacement.functions] A C ++ program may provide the definition for any of twelve dynamic memory allocation function signatures
declared in header <new>
In practice, since a free standing environment cannot depend on an OS, and malloc
is usually implemented using features provided by an OS, it is unlikely to have free store memory management features in a freestanding environment. Conversely, a hosted environment requires free store memory management to implement the features of the standard library.