Mail Archives: djgpp/1997/07/30/14:52:15
You wrote:
>How do I link my own extra entry/exit code into a c project?
Okay, here are three ways, in increasing order of difficulty.
- Run your entry code at the beginning of `main', and use `atexit' to set up
exit code. (Trivial, but often sufficient.)
- Use the GNU extensions "constructor" and "destructor". That would look
something like this:
void hello(void) __attribute__ ((constructor));
void bye(void) __attribute__ ((destructor));
void hello(void) { /* ... do stuff ... */ }
void bye(void) { /* ... do more stuff ... */ }
- Rewrite crt0.o.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -