本文介绍了还有几个 SWIG 警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试围绕 C++ 库创建一些 ruby​​ 包装器.我已经完成了大部分工作,但我有一些警告需要修复.

I am trying to create some ruby wrappers around a c++ library.I have most of it working, but I have a few Warnings that I would like to fix.

问题与 2 个头文件有关,这里是代码片段

The issues are with 2 header files, here are the snips of code

typedef std::set<WParm,std::less<WParm> > WParmlistType;
typedef WParmlistType::iterator  WParmlistIter;

class WParmlist : public WParmlistType {

以及我收到的警告...警告 401:对基类WParmlistType"一无所知.忽略.

and the warning I get ...Warning 401: Nothing known about base class 'WParmlistType'. Ignored.

和第二个标题相似:

typedef std::vector<WString> WEditType;
typedef WEditType::iterator  WEditIter;

class WEdit : public WEditType {

带有类似警告:

警告 401:对基类WEditType"一无所知.忽略.

Warning 401: Nothing known about base class 'WEditType'. Ignored.

我以前见过这种类型的警告,但这与从 std::string 继承有关.这些造成了真正的问题,因为我无法获得返回的字符串值.由于在这里找到的答案,我能够通过使用 %include std_string.i 来解决这个问题:swig 对基类 'std::string' 一无所知,忽略.我在想在这种情况下我可能需要其他一些指令来处理 typedef.

I had seen this type of warning before, but that was related to inheritance from std::string. Those caused real problems in that I was unable to get the returned string values. I was able to get past that by using %include std_string.i, thanks to the answer found here : swig Nothing known about base class 'std::string', ignored . I was thinking there was some other directive I may need to handle the typedefs in this situation.

推荐答案

这只是一个警告,说明您将无法在 ruby​​ 中实例化 WEditType 或 WParmlistType.您能够实例化派生类 WEdit 和 WParmList,只是不能实例化基类.仅当您想从 WEditType 或 WParmlistType in ruby​​ 派生新类时,这才重要.如果没有,您可以忽略警告.请始终查看位于 http://www.swig.org/Doc2.0/的 SWIG 文档.例如,我在 http://www.swig.org/Doc2.0/SWIGPlus.html#SWIGPlus_nn20.此外,始终使用 google 进行搜索,尤其是查看 SO 上的结果.对错误消息的搜索显示 Avoid 'nothing known about [parent] class...' swig 中的错误,提供了类似的解释.

It is just a warning saying that you won't be able to instantiate WEditType or WParmlistType in ruby. You will be able to instantiate the derived classes WEdit and WParmList, just not the base classes. This matters only if you want to derived new classes from WEditType or WParmlistType in ruby. If not, you can just ignore the warning. Always take a look at the SWIG docs at http://www.swig.org/Doc2.0/. For instance there is a good explanation of what I said at http://www.swig.org/Doc2.0/SWIGPlus.html#SWIGPlus_nn20. Also, always do a search with google, especially look at results on SO. A search for the error message showed Avoid 'nothing known about [parent] class...' error in swig, which provides similar explanations.

这篇关于还有几个 SWIG 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 22:58