Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SWIG包装器正在向类名添加新的前缀,但无法获取类方法 我编写了简单的C++空余函数的包装器,它使用2个字符串参数。 由于某些原因,当我尝试创建我的类的对象时,我得到一个名称错误“name‘my class name’未定义”。 当我尝试在创建对象的类名之前创建对象并指定新的前缀时,我仍然无法使用类似的名称技巧调用我的函数。 以下是接口和类的代码: %module python_module %{ #include "python_wrapper.h" %} %import std_string.i %include "python_module.h"_Python_C++_Swig - Fatal编程技术网

SWIG包装器正在向类名添加新的前缀,但无法获取类方法 我编写了简单的C++空余函数的包装器,它使用2个字符串参数。 由于某些原因,当我尝试创建我的类的对象时,我得到一个名称错误“name‘my class name’未定义”。 当我尝试在创建对象的类名之前创建对象并指定新的前缀时,我仍然无法使用类似的名称技巧调用我的函数。 以下是接口和类的代码: %module python_module %{ #include "python_wrapper.h" %} %import std_string.i %include "python_module.h"

SWIG包装器正在向类名添加新的前缀,但无法获取类方法 我编写了简单的C++空余函数的包装器,它使用2个字符串参数。 由于某些原因,当我尝试创建我的类的对象时,我得到一个名称错误“name‘my class name’未定义”。 当我尝试在创建对象的类名之前创建对象并指定新的前缀时,我仍然无法使用类似的名称技巧调用我的函数。 以下是接口和类的代码: %module python_module %{ #include "python_wrapper.h" %} %import std_string.i %include "python_module.h",python,c++,swig,Python,C++,Swig,python_wrapper.h #ifndef PYTHON_WRAPPER_H #define PYTHON_WRAPPER_H #include <string> class Separator { public: Separator(); ~Separator(); public: void separate(const std::string& Path, const std::string& destFolder); }; #endif

python_wrapper.h

#ifndef PYTHON_WRAPPER_H
#define PYTHON_WRAPPER_H

#include <string>

class Separator
{
public:
  Separator();
  ~Separator();

public:
  void separate(const std::string& Path, const std::string& destFolder);
};

#endif
有人能帮忙吗

同时,当我发短信的时候

>>> separator = new_Separator()

对象正在创建,但即使在此之后,我也无法调用我的函数。

使用pybin11代替SWIG。对于我的任务来说,这比swig更容易解决

    python3
>>> from _MyModule import *
>>> separator = Separator()
I'm getting name error : name 'Separator' is not defined.
>>> separator = new_Separator()