diff --git a/doc/ca65.sgml b/doc/ca65.sgml index b147ce540..145404205 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -846,16 +846,16 @@ Here's a list of all control commands and a description, what they do: id=".DESTRUCTOR" name=".DESTRUCTOR"> commands are actually shortcuts for - .condes ModuleInit, constructor - .condes ModInit, 0, 16 + .condes ModuleInit, constructor + .condes ModInit, 0, 16 See the and , , , and + name=".PSC02">, , and @@ -2843,6 +2845,19 @@ two bytes in the table (a pointer to the function). +Calling order

+ +Both, constructors and destructors are sorted in increasing priority order by +the linker when using one of the builtin linker configurations, so the +functions with lower priorities come first and are followed by those with +higher priorities. The C library runtime subroutine that walks over the +constructor and destructor tables calls the functions starting from the top of +the table - which means that functions with a high priority are called first. + +So when using the C runtime, both constructors and destructors are called with +high priority functions first, followed by low priority functions. + + Pitfalls

When creating and using module constructors and destructors, please take care