Proposal 2: Exceptions and @nogc

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 11 10:21:16 PDT 2017


On 4/11/2017 1:54 AM, Jonathan M Davis via Digitalmars-d wrote:
>> No. D can catch C++ exceptions.
>
> What does this look like? I recall you discussing planning adding the
> ability for D to catch C++ exceptions, but I was unaware that it had been
> implemented yet. Certainly, I couldn't find it in the documentation when I
> went looking a month or two back. But I wouldn't think that catching
> Exception would work if it's a C++ exception - even if it's a
> std::exception, since std::exception doesn't have the same functions as
> Exception or Throwable. So, how would you catch a C++ exception in D?

You define a C++ class in D that matches a C++ one, throw a pointer to that 
class in C++, and catch it in D.

It currently works on Elf and MachO, but not on Windows.



More information about the Digitalmars-d mailing list