prolog and epilog code

Rufus Smith via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 2 09:21:07 PDT 2016


On Tuesday, 2 August 2016 at 11:37:05 UTC, Steven Schveighoffer 
wrote:
> On 8/1/16 9:24 PM, Rufus Smith wrote:
>> Can one add code that executes before the GC and any memory is 
>> normally
>> allocated(even static) and after all of it was suppose to be 
>> released?
>
> Of course! You just have to modify druntime :)

That doesn't sound like fun. Why doesn't D add a hook for program 
level static this(we have module level, need something more)?

> One thing you can do instead is compile without a D main 
> function, and use C main, initialize the runtime manually. Then 
> you can put your measurement code around the runtime 
> initialization and termination.

How does one use C main? extern C? Or do I have to actually write 
C code?




More information about the Digitalmars-d-learn mailing list