C++: Difference between revisions

Jump to navigation Jump to search
17 bytes added ,  14 years ago
[unchecked revision][unchecked revision]
Line 57:
Global or static objects have to be constructed by the environment before they are available for C++ code. Care should be taken if global/static objects need new and delete in their constructors. In this case it is best to construct global/static objects only after your kernel heap is ready for use. Not doing so can cause an object to attempt to allocate memory via the non-working new operator. This also simplifies the storing of the destructor functions in <tt>__cxa_atexit</tt>, because you don't have to use a static and fixed-size structure.
 
According to the [http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/baselib---cxa-atexit.html Itanium C++ Application Binary Interface], the function <tt>__cxa_atexit</tt> is used to register a destructor to be called when a shared library is to be unloaded. This function should insert a function pointer, with (max) one accompanying argument, and the handle of the object or shared resource to be destroyed, into a table. In the source example for an implementation of <tt>__cxa_atexit</tt>, the <tt>struct object__atexit_funcs[32ATEXIT_MAX_FUNCS]</tt> array acts as the table.;
</tt> array acts as the table.
 
This is why, below, the function <tt>__cxa_atexit</tt> is defined as:
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu