@@ -7241,3 +7241,33 @@ the variables were declared in. It is not possible to check the return value
72417241(if any) of these ``cleanup`` callback functions.
72427242}];
72437243}
7244+
7245+ def CtorDtorDocs : Documentation {
7246+ let Category = DocCatFunction;
7247+ let Content = [{
7248+ The ``constructor`` attribute causes the function to be called before entering
7249+ ``main()``, and the ``destructor`` attribute causes the function to be called
7250+ after returning from ``main()`` or when the ``exit()`` function has been
7251+ called. Note, ``quick_exit()``, ``_Exit()``, and ``abort()`` prevent a function
7252+ marked ``destructor`` from being called.
7253+
7254+ The constructor or destructor function should not accept any arguments and its
7255+ return type should be ``void``.
7256+
7257+ The attributes accept an optional argument used to specify the priority order
7258+ in which to execute constructor and destructor functions. The priority is
7259+ given as an integer constant expression between 101 and 65535 (inclusive).
7260+ Priorities outside of that range are reserved for use by the implementation. A
7261+ lower value indicates a higher priority of initialization. Note that only the
7262+ relative ordering of values is important. For example:
7263+
7264+ .. code-block:: c++
7265+
7266+ __attribute__((constructor(200))) void foo(void);
7267+ __attribute__((constructor(101))) void bar(void);
7268+
7269+ ``bar()`` will be called before ``foo()``, and both will be called before
7270+ ``main()``. If no argument is given to the ``constructor`` or ``destructor``
7271+ attribute, they default to the value ``65535``.
7272+ }];
7273+ }
0 commit comments