How to compile Phobos with other D code to create a shared library?

Steven Schveighoffer schveiguy at gmail.com
Mon May 31 21:26:15 UTC 2021


On 5/31/21 5:20 PM, data pulverizer wrote:
> On Monday, 31 May 2021 at 21:01:19 UTC, Steven Schveighoffer wrote:
>>
>> ticksPerSecond is initialized in the runtime just before static 
>> constructors are run. See 
>> https://github.com/dlang/druntime/blob/2d8b28da39e8bc3bc3172c69bb96c35d77f40d2a/src/rt/dmain2.d#L130 
>>
>>
>> Are you calling Runtime.initialize()?
> 
> 
> Nope, I guess I'm supposed to be? if so where do I place the call(s) for 
> initialize() and terminate()?
> 
> 

You need to call it wherever you think it might not have been called yet.

It's reentrant, so if you call it more than once, it will only 
initialize once, and count how many times you have to call 
`Runtime.terminate`.

Best to use a `scope(exit)` to call `Runtime.terminate` if you are 
calling it periodically.

-Steve


More information about the Digitalmars-d-learn mailing list