From: cuz Date: Tue, 12 Aug 2003 10:29:06 +0000 (+0000) Subject: Clarify calling order for constructors/destructors X-Git-Tag: V2.12.0~1460 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=53dc9dedf0e8ced122204f547ab449bb314930fa;p=cc65 Clarify calling order for constructors/destructors git-svn-id: svn://svn.cc65.org/cc65/trunk@2266 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- 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