问题
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.
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 {
and the warning I get ... Warning 401: Nothing known about base class 'WParmlistType'. Ignored.
and the second header is similar :
typedef std::vector<WString> WEditType;
typedef WEditType::iterator WEditIter;
class WEdit : public WEditType {
with a similar warning:
Warning 401: Nothing known about base class 'WEditType'. Ignored.
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.
回答1:
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.
回答2:
When you use templates in SWIG, you can let SWIG know what templates you use so it can generate wrapper code for it. In the case of vector<WString>
, you can use:
%include <std_vector.i>
%template() std::vector<WString>;
来源:https://stackoverflow.com/questions/20603707/a-couple-more-swig-warnings