On Tuesday, 20 February 2024 at 18:33:42 UTC, Carl Sturtivant wrote:
1.
When the resulting executable runs it will have D call C which in turn calls D. In that last D (the D files replacing some C files), if I throw an exception and don't catch it in the D files that replace some C files, will it propagate correctly to the D main function where I can catch it?

My understanding is that [this reply](https://forum.dlang.org/post/ur5g46$fmb$1...@digitalmars.com) indicates that this works. Exceptions thrown by D can be caught by D in general in the presence of ImportC.

2.
The C source calls exit() from C's stdlib, and D needs to terminate properly. Throwing an exception and catching it in D's main function seems to be a way to achieve this. What is the best way to deal with exit() ?

So I can simulate C's exit() by throwing an exception and catching it in main() as [suggested here](https://forum.dlang.org/post/mailman.5856.1600355565.31109.digitalmars-d-le...@puremagic.com).

3.
I want to use D's remarkable Fiber class to reimplement a deterministic stack changing context switch that in the original project is achieved with assembly code on a per-platform basis. This will mean that D's main function will call C which will call D which will effect a context switch. Is there any reason to believe this will work as naively hoped?

I'll have to proceed experimentally, but I'd like to know in advance if this is doomed. Anyone?

Reply via email to