如何集成 C++可以在 swig 接口文件中抛出 MyException 的函数

发布于 2024-09-03 19:41:50 字数 161 浏览 2 评论 0原文

我是 swig 的新手,使用 swig 将 C++ 代码集成到 Perl,我有像这样的 C++ 函数 void s() 抛出 MyException。 我如何在 swig 接口文件中集成可以抛出 MyException 的 C++ 函数。如何在 Perl 中调用 C++ 函数。 非常感谢这方面的任何帮助。

I am new to swig,using swig for integrating c++ code to Perl,I have c++ function like
void s() throw MyException.
How i can integrate the c++ function that can throw the MyException in the swig interface file.How i can called the c++ function in Perl.
Any Help in this regard is highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴我心暖 2024-09-10 19:41:50

如果您还没有完全决定使用 swig 来包装 C++,那么也许可以看看 异常处理代码 我为 ExtUtils::XSpp 工具。

默认情况下,它非常方便地将 C++ 异常转换为 Perl 异常。为了进行更细粒度的控制,您可以向包装器声明异常类型并指定如何处理它们。

If you're not entirely set on using swig for wrapping your C++, then maybe have a look at the exception handling code I wrote for the ExtUtils::XSpp tool.

It quite conveniently converts C++ exceptions to Perl exceptions by default. For more fine-grained control, you can declare your exception types to the wrapper and specify how they are supposed to be treated.

脸赞 2024-09-10 19:41:50

这里'涉及Python的链接。
这里是来自 Swig 网站的 C++ 异常的链接。
这里是异常处理的链接。

基本上,您需要设置 *.i 文件来告诉 Perl 代码如何处理异常。 Swig 网站上有很好的文档。很抱歉我无法提供更多帮助。我不懂 Perl,也没有使用 Swig 和 Perl 的经验。我也遇到了 Swig 和异常问题。

Here's a link that involves Python.
Here's the links to exceptions with C++ from the Swig website.
Here's a link to exception handling.

Basically you're going to need to set up your *.i file to tell the Perl code how to handle the exceptions. There's good documentation on the Swig website. I'm sorry I can't be of more help. I don't know Perl and have no experience with Swig and Perl. I'm also having problems with Swig and exceptions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文