【问题标题】:swig perl wrapper is not generating for class member functionsswig perl 包装器没有为类成员函数生成
【发布时间】:2016-04-05 05:37:32
【问题描述】:

我有如下简单的 c++ 类 //example.h

#include<iostream>
class example
{
public:
    int member;
    void display(){
        std::cout<<"Hello from example class"<<std::endl;
        }
};

//我的example.i文件是

%module example
%{
#include "example.h"
%}
%include "example.h"

在此之后我正在运行

pkgs/swig/2.0.8/bin/swig -c++ -perl5 example.i 但我没有看到在 .pm 模块中为我的显示功能定义的包装器由此生成。 任何工作样本都会有很大帮助。

谢谢, 哈里什

【问题讨论】:

    标签: perl swig


    【解决方案1】:

    即使我没有看到用于显示方法的特殊包装器,但我看到生成了类似下面的内容,并且当我尝试从 perl 访问它时它工作了

    *display = *examplec::example_display;
    

    我的代码来访问 c++ 类对象

    use example;
    $myObj =new example::example();
    $myObj->{member} = 1000;
    print $myObj->{member};
    print "\n";
    $myObj->display();
    print "\nFinished";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-29
      • 1970-01-01
      • 1970-01-01
      • 2020-03-10
      相关资源
      最近更新 更多