9.34 __attribute__((destructor[(priority)])) function attribute

This attribute causes the function it is associated with to be called automatically after main() completes or after exit() is called.


This attribute is a GNU compiler extension that the ARM compiler supports.


Where priority is an optional integer value denoting the priority. A destructor with a high integer value runs before a destructor with a low value. A destructor with a priority runs before a destructor without a priority.
Priority values up to and including 100 are reserved for internal use. If you use these values, the compiler gives a warning. Priority values above 100 are not reserved.


int my_destructor(void) __attribute__((destructor));
int my_destructor(void) /* This function is called after main() */
{                       /* completes or after exit() is called. */
   return 0;
Related reference
Related information
--fini=symbol linker option
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.