linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Smith <sos22@cantab.net>
To: "David L. Martin" <dlmarti@kc2lcf.net>
Cc: C programming list <linux-c-programming@vger.kernel.org>,
	sos22@srcf.ucam.org
Subject: Re: Automatic library init
Date: Sun, 5 Jun 2005 14:50:08 +0100	[thread overview]
Message-ID: <20050605135008.GA1880@localhost> (raw)
In-Reply-To: <1117935271.4561.3.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

> Back in the day (Borland days), there used to be a pragma directive that
> could be used to automatically call a function with-in the library on
> startup.  I know something like this must exist in gcc but I can't find
> it.
I think the approved method is to use constructor functions:

void cons_func(void) __attribute__((constructor));

void cons_func(void)
{
	/* Do initialisation stuff here */
}

Note that it isn't hugely well defined what order constructor
functions get called in, so be careful when calling other libraries.

Steven.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

      reply	other threads:[~2005-06-05 13:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-05  1:34 Automatic library init David L. Martin
2005-06-05 13:50 ` Steven Smith [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050605135008.GA1880@localhost \
    --to=sos22@cantab.net \
    --cc=dlmarti@kc2lcf.net \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=sos22@srcf.ucam.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).