| |||
| Home > Compiler-specific Features > __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 supported by the ARM compiler.
__attribute__((destructor[(priority)]))
Where 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
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=if
you are using GNU makefiles unmodified to build with the ARM compiler.
That is, if you are using symbol --translate_gcc, --translate_gld,
or --translate_g++.
int my_destructor(void) __attribute__((destructor)); int my_destructor(void) /* This function is called aftermain()*/ { /* completes or afterexit()is called. */ ... return 0; }