* Automatic library init
@ 2005-06-05 1:34 David L. Martin
2005-06-05 13:50 ` Steven Smith
0 siblings, 1 reply; 2+ messages in thread
From: David L. Martin @ 2005-06-05 1:34 UTC (permalink / raw)
To: C programming list
I am updating a whole set of libraries at work, one of the complaints I
am dealing with is the need to initialize the library.
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.
Does anyone have info?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Automatic library init
2005-06-05 1:34 Automatic library init David L. Martin
@ 2005-06-05 13:50 ` Steven Smith
0 siblings, 0 replies; 2+ messages in thread
From: Steven Smith @ 2005-06-05 13:50 UTC (permalink / raw)
To: David L. Martin; +Cc: C programming list, sos22
[-- 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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-05 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-05 1:34 Automatic library init David L. Martin
2005-06-05 13:50 ` Steven Smith
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.