C++/D interface: exceptions

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 11 20:19:25 PDT 2014


On Friday, 12 September 2014 at 00:34:52 UTC, Andrei Alexandrescu 
wrote:
> Hello,
>
>
> We are racking our brains to figure out what to do about 
> exceptions thrown from C++ functions into D code that calls 
> them.
>
> A few levels of Nirvana would go like this:
>
> 0. Undefined behavior - the only advantage to this is we're 
> there already with no work :o).
>
> 1. C++ exceptions may be caught only by C++ code on the call 
> stack; D code does the stack unwinding appropriately (dtors, 
> scope statements) but can't catch stuff.
>

This is what SDC does.

> 2. D code can catch exceptions from C++ (e.g. via a 
> CppException wrapper class) and give some info on them, e.g. 
> the what() string if any.
>

This would require that druntime to be dependent on C++ runtime.


More information about the Digitalmars-d mailing list