You copied the Doc URL to your clipboard.

__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.

Note 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.


This attribute can be preferable to the linker option --fini=symbol if you are using GNU makefiles unmodified to build with the ARM compiler. That is, if you are using --translate_gcc, --translate_gld, or --translate_g++.


int my_destructor(void) __attribute__((destructor));
int my_destructor(void) /* This function is called after main() */
{                       /* completes or after exit() is called. */
   return 0;
Was this page helpful? Yes No