how to catch D Throwables (or exceptions) from C++?
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Nov 30 21:29:46 PST 2016
On Thursday, 1 December 2016 at 01:58:13 UTC, Timothee Cour wrote:
> eg:
>
> ```
> dlib.d:
> extern(C) void dfun(){assert(0, "some_msg");}
>
> clib.cpp:
> extern "C" void dfun();
> void fun(){
> try{
> dfun();
> }
> catch(...){
> // works but how do i get "some_msg" thrown from D?
> }
> }
> ```
portably not sure, but if you're using dwarf / libunwind you can
probably use the API directly and get a pointer to the exception
object and dereference a field of it's (i.e. p+
Throwable.msg.offsetof ).
More information about the Digitalmars-d-learn
mailing list