Re: gcc option for constructor and destructors
- From: William Pursell <bill.pursell@xxxxxxxxx>
- Date: Wed, 9 Apr 2008 07:53:56 -0700 (PDT)
On Apr 9, 7:26 am, sinbad <sinbad.sin...@xxxxxxxxx> wrote:
i want to write a constructor and destructor function in c for each of
the function.
I should register a routines which will be called before calling the
function and destructor before actual return of the original function.
Does gcc provides anything like this.
gcc allows you to put a cleanup attribute on one of the
automatic variables which would give you the destructor.
http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Variable-Attributes.html#Variable%20Attributes
To simulate a constructor, you can overload the function
by giving your constructor the same name as the
function and then use dlsym( RTLD_NEXT,...) to
call the function itself.
You're probably better off just modifying
the function to start by calling your constructor/initializer
and end by calling the destructor.
.
- References:
- gcc option for constructor and destructors
- From: sinbad
- gcc option for constructor and destructors
- Prev by Date: Re: gcc option for constructor and destructors
- Next by Date: Re: Trying to monitor a previous child process
- Previous by thread: Re: gcc option for constructor and destructors
- Next by thread: Re: gcc option for constructor and destructors
- Index(es):
Relevant Pages
|