Any libunwind experts n da house?

IgorStepanov via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 24 15:40:27 PDT 2014


On Wednesday, 24 September 2014 at 22:14:5 UTC, Andrei
Alexandrescu wrote:
> On 9/24/14, 2:53 PM, IgorStepanov wrote:
>>
>> I have one freaky example for you. This example can be
>> non-standart and danger but it works:
>> C++ side: http://pastebin.ru/PceYCOEq
>> special function catch exception, pass it to specified handler
>> and re-throw, if handler not found
>>
>> D side: http://pastebin.ru/7FNBzXHw
>> D defines a special handler and pass it to catchException
>> result:
>> D code call C++ function
>>
>> void throwEx(void *)
>> {
>>      throw 4;
>> }
>> and prints:
>> dside.CPPException!int.CPPException@(0): 4
>>
>> Doesn't fire to me, please :)
>
> Awesome! How do we make it standard and safe? -- Andrei
C++ hasn't standart abi(
If we talk about g++, this code has a one conspicuous trouble: I
don't know, how to correctly get a pointer to exception. Class
exception_ptr has getter for it, but it is private. I'll think
about another variants.
And I don't know about <cxxabi.h> standartness.
The second trouble: if we want to do something more exception
printing, we should get an exception pointer to user. However,
user shouldn't copy this pointer, because exception object will
be destroyed in cpp side.
Good news: this code (D side) can be generated by D compiler:
try
{
      // C++ exceptions danger
}
catch(CPPException!int e)
{
}
catch(CPPException!myException e)
{
}

Of course, only exact match of exception will be works. No
polymorphism.


More information about the Digitalmars-d mailing list