douzi5214 2015-11-10 01:20
浏览 15

Golang的缠绕包装

I'm having trouble to use swig to wrap a c++ library for golang. Here is my c++ header file.

class Builder {
 public:
  explicit Builder(int i):counters(i){} 
  void Init(); 
  void CreateCounters(vector<std::unique_ptr<int>>* s);
  bool CreateEntry(string* primary_key);
 private:
  std::shared_ptr<hash_set<string>> ids;
  int counters;
};

I just want to wrap Builder class and its constructor, Init() and CreateEntry function. Here is my swig API

%{
#include "builder.h"
%}

%ignoreall

%unignore Builder;
%unignore Builder::Init();
%unignore CreateEntry(string* primary_key);

%include "builder.h"

%unignoreall

But when I compile I get error pointing to the CreateCounters function which has a argument of unique_ptr vector. Can anyone tell me whats wrong in here?

Thanks in advance :)

  • 写回答

1条回答 默认 最新

  • dov11020 2015-11-10 03:36
    关注

    Your swig file doesn't have a module name. Try this...

    %module builder
    %{
    #include "builder.h"
    %}
    
    %ignoreall
    
    %unignore Builder;
    %unignore Builder::Init();
    %unignore CreateEntry(string* primary_key);
    
    %include "builder.h"
    
    %unignoreall
    

    The module name translates to the name of the package your wrapped code resides in.

    Also for c++ code, ensure your swig file is named something like 'builder.swigcxx' the extension is important as otherwise it'll assume you're wrapping pure C.

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题