The exceptions system can be initialized either on demand
(that is, when first used), or before main is
entered. Initialization on demand has the advantage of not allocating
heap memory unless the exceptions system is used, but has the disadvantage
that it becomes impossible to throw any exception (such as std::bad_alloc)
if the heap is exhausted at the time of first use.
The default behavior is to initialize on demand. To initialize
the exceptions system before main is entered,
include the following function in the link:
Although you can place the call to __cxa_get_globals directly
in your code, placing it in __ARM_exceptions_init ensures
that it is called as early as possible. That is, before any global variables
are initialized and before main is entered.
__ARM_exceptions_init is weakly referenced
by the library initialization mechanism, and is called if it is
present as part of __rt_lib_init.
Note
The exception system is initialized by calls to various library
functions, for example, std::set_terminate().
Therefore, you might not have to initialize before the entry to main.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.