RFC: Constructor and destructor priority attributes

2007-02-22 Thread Mark Mitchell

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
[EMAIL PROTECTED]
(650) 331-3385 x713



Re: RFC: Constructor and destructor priority attributes

2007-02-22 Thread Andrew Pinski
> 
> 
> CodeSourcer's VxWorks toolchains support the following extension to
> __attribute__((constructor)):
> 
>   void f __attribute__((constructor (N)));
> 
> I plan to merge this functionality to the GCC mainline.  Does anyone
> object to this feature, in principle?

I think this is a great extension as someone was requesting the same thing
here too.

Thanks,
Andrew Pinski