This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RFC: Constructor and destructor priority attributes
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 22 Feb 2007 14:52:20 -0800
- Subject: RFC: Constructor and destructor priority attributes
- Reply-to: mark at codesourcery dot com
CodeSourcer's VxWorks toolchains support the following extension to
__attribute__((constructor)):
void f __attribute__((constructor (N)));
The number provided is a constructor priority. These are treated
exactly like the arguments to the C++ init_priority attribute, which
allows control over initialization priority order for namespace-scope
C++ objects. The implementation is the same, too; all the C++
init_priority attribute does is create a magic function which is then
given the appropriate priority. So, what this does is expose the
functionality used for C++ for direct use from C.
The attribute syntax above works in both C and C++, and is
backwards-compatible; without the "(N)" you just get the default
initialization priority, as you do at present.
I plan to merge this functionality to the GCC mainline. Does anyone
object to this feature, in principle?
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713