[Gc] RE: Using the GC from a DLL

Boehm, Hans hans.boehm at hp.com
Thu Jan 3 15:10:41 PST 2008

> -----Original Message-----
> From: Achilleas Margaritis [mailto:axilmar at otenet.gr]
> So do I have to call GC_INIT or not?
The short, safe answer is yes.  There are platforms (currently cygwin and AIX, I believe) on which your code won't work without it.  It is strongly recommended that you call it from the main program (not from a DLL) before you make any other GC calls.

The longer answer is that on common platforms you should often be able to get away without it, and trying to insist that it always be called first on all platforms, as in 7.0, turned out to be problematic.  In the CVS version, you can get away with calling GC_malloc first (and having it perform the initialization) instead of calling GC_INIT on nearly all platforms.   But if you need maximal portability, you can't.

That's not as simple an answer as I would like.  But it seems to be as simple as we can make it.


> If I do, do I have to call it from main, WinMain or it does
> not matter?
> O/H Boehm, Hans έγραψε:
> > The CVS version forces initialization on a GC_malloc call.
> Version 7.0 does not.  Even with the CVS version, some more
> esoteric calls might cause problems if they are made before
> initialization.
> >
> > Hans
> >
> >> -----Original Message-----
> >> From: gc-bounces-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org
> >>
> [mailto:gc-bounces-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org]
> >> On Behalf Of Achilleas Margaritis
> >> Sent: Monday, December 31, 2007 1:47 AM
> >> To: gc-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org
> >> Subject: [Gc] Using the GC from a DLL
> >>
> >> How can I use the GC from inside a DLL?
> >>
> >> What if the DLL does allocations in its initialization
> code before I
> >> am given a chance to call GC_INIT?
> >>
> >> _______________________________________________
> >> Gc mailing list
> >> Gc-V9/bV5choksm30D7ZfaTJw at public.gmane.org
> >> https://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> >>

More information about the Gc mailing list