C++/D interface: exceptions

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 12 09:35:52 PDT 2014


On Fri, Sep 12, 2014 at 06:19:54PM +0200, Marco Leise via Digitalmars-d wrote:
> Am Fri, 12 Sep 2014 15:55:37 +0000
> schrieb "Sean Kelly" <sean at invisibleduck.org>:
> 
> > On Friday, 12 September 2014 at 06:56:29 UTC, Jacob Carlborg 
> > wrote:
> > > On 64bit Objective-C can catch C++ exceptions. But I don't 
> > > think you can do anything with the exception, i.e. it uses the 
> > > following catch syntax:
> > >
> > > @catch(...) {}
> > >
> > > Would that be easier?
> > 
> > I think the trick is setting up the stack frame in such a way 
> > that the C++ exception mechanism knows there's a catch block 
> > available at all.  From there, we should be able to use the 
> > standard interface-to-class method to call virtual functions on 
> > the exception object, and hopefully the C++ runtime will handle 
> > cleanup for us.
> 
> What exception object?
> 
> throw "bad things happened";
[...]

Yeah, in C++, you can throw *anything*. Including ridiculous things like
`throw NULL;` or `throw 3.14159;`. There's no method for that! What we
might end up doing, might be to wrap the C++ exception in a D exception
that contains a pointer to the C++ type along with whatever type info we
can glean from the C++ runtime. We probably won't be able to do much
more than that.


T

-- 
Bomb technician: If I'm running, try to keep up.


More information about the Digitalmars-d mailing list