[Gc] Re: Using the GC from a DLL

Achilleas Margaritis axilmar at otenet.gr
Thu Jan 3 16:06:57 PST 2008



So, if I understand correctly:

1) I can call GC_malloc either from a DLL, or from initialising a global 
variable in the program before main is invoked.
2) when main is invoked, I must call GC_INIT.

Can you please confirm that the above are true?

O/H Boehm, Hans έγραψε:
>> -----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.
>
> Hans
>
>   
>> 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
>>>> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>>>>
>>>>         
>>
>>     
>
>
>
> __________ NOD32 2760 (20080102) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
>
>   





More information about the Gc mailing list