cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/30/14:52:15

Date: Wed, 30 Jul 1997 11:51:14 -0700 (PDT)
Message-Id: <199707301851.LAA11762@adit.ap.net>
Mime-Version: 1.0
To: darn AT xl DOT ca
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: custom entry/exit code
Cc: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019