D exceptions and calling c++ code

Timothee Cour thelastmammoth at gmail.com
Sat Mar 30 02:11:49 PDT 2013


this might be relevant: see code that Swig generates when writing C++ wrappers :

eg:
----
// Support for throwing D exceptions from C/C++.
typedef enum {
  SWIG_DException = 0,
  SWIG_DIllegalArgumentException,
  SWIG_DIllegalElementException,
  SWIG_DIOException,
  SWIG_DNoSuchElementException,
} SWIG_DExceptionCodes;

typedef void (* SWIG_DExceptionCallback_t)(const char *);
----

On Fri, Mar 29, 2013 at 10:06 PM, J <noname at notavailable.notavailabe.com> wrote:
> Is there anything that would prevent D from catching C++ exceptions?
>
> It would be nice to be able to leverage C++ libraries, but if you can't
> catch C++ exceptions, I'm not sure how realistic that is.
>
> That doesn't mean that catch() in D has to be the catcher.
>
> If there was some way to indicate that a function call was into a C++
> library, and perhaps some way to auto-generate, at the call point, the
> boilerplate that does the "catch this C++ exception and re-throw it as a D
> exception" translation, that would be awesome.
>
> Possible?


More information about the Digitalmars-d mailing list