为覆盖 std::exception 的库生成 swig 接口时出错
Error generating swig interface for library which overrides std::exception
我正在尝试为具有继承自 std::exception
的 class 的库生成一个 swig 接口。我似乎无法让它工作。
这是一个简单的例子。 mylib.h
的代码:
#pragma once
#include <exception>
class CustomException : public std::exception
{
};
这是 mylib.i
的代码:
%module mylib
%{
#include "mylib.h"
%}
/*
Run without anything:
mylib.h:5: Warning 401: Nothing known about base class 'std::exception'. Ignored.
*/
/*
Run with: %include <exception>
mylib.i:11: Error: Unable to find 'exception'
*/
/*
Run with: %include exception.i
mylib.h:5: Warning 401: Nothing known about base class 'std::exception'. Ignored.
*/
%include "mylib.h"
正如您在 mylib.i
的评论中看到的那样,swig 似乎很难弄清楚 std::exception
是什么。
使用%include <std_except.i>
:
%module test
%include <std_except.i>
%inline %{
class CustomException : public std::exception
{
};
%}
我正在尝试为具有继承自 std::exception
的 class 的库生成一个 swig 接口。我似乎无法让它工作。
这是一个简单的例子。 mylib.h
的代码:
#pragma once
#include <exception>
class CustomException : public std::exception
{
};
这是 mylib.i
的代码:
%module mylib
%{
#include "mylib.h"
%}
/*
Run without anything:
mylib.h:5: Warning 401: Nothing known about base class 'std::exception'. Ignored.
*/
/*
Run with: %include <exception>
mylib.i:11: Error: Unable to find 'exception'
*/
/*
Run with: %include exception.i
mylib.h:5: Warning 401: Nothing known about base class 'std::exception'. Ignored.
*/
%include "mylib.h"
正如您在 mylib.i
的评论中看到的那样,swig 似乎很难弄清楚 std::exception
是什么。
使用%include <std_except.i>
:
%module test
%include <std_except.i>
%inline %{
class CustomException : public std::exception
{
};
%}