SWIG wrapping C++ for Python: translating a list of strings to an STL vector of STL strings

后端 未结 2 1816
清歌不尽
清歌不尽 2020-12-31 16:01

I would like to wrap a C++ function with SWIG which accepts a vector of STL strings as an input argument:

#include 
#include 
#         


        
2条回答
  •  天涯浪人
    2020-12-31 16:24

    SWIG does support passing a list to a function that takes a vector as value, or a const vector reference. The example at http://www.swig.org/Doc2.0/Library.html#Library_std_vector shows this, I can't see anything wrong with what you posted. Something else is wrong; DLL found by python was't the latest, the using namespace std in the header is confusing the SWIG wrapper code that does the type checking (note that "using namespace" statements in .hpp is a no-no in general as it pulls everything from std into global namespace), etc.

提交回复
热议问题