我有包含以下类型定义的 C 头文件:
// example.h
typedef struct Vertex {
int color;
} Vertex;
我尝试用 SWIG 包装这个结构,但显然我做错了什么。我的 SWIG 接口文件看起来像
// example.i
%module example
%inline %{
#include "example.h"
}
但是如果我将头文件的内容复制到我的接口文件中,以便后者看起来像
%module example
%inline %{
typedef struct Vertex {
int color;
} Vertex;
%}
我可以通过以下方式从 Ruby 访问结构
irb> require 'example'
# => true
irb> Examlpe::Vertex
# => Vertex
有没有办法自动包装头文件?不想每次改头文件的时候都把头文件的内容复制粘贴到接口文件中。
在此先感谢您的帮助。
-- t6d