Swig 简单类型 typedef 参数
Swig simple type typedef argument
我为swig到lua中的简单类型创建了C++typedef,类似于
namespace numbers {
typedef float float4;
}
我还创建了函数
numbers::float4 foo();
void foo1( numbers::float4 );
路易代码
result = foo()
foo1( result )
错误:
Lua error: Wrong arguments for overloaded function
Possible C/C++ prototypes are:
foo1( numbers::float4 )
SWIG似乎可以识别数字::float4,但是在创建Lua变量时,它不知何故会感到困惑。
评论太长了:
我无法在问题中重现该问题。 您可以尝试以下步骤,看看是否仍然收到错误吗?
我有以下C++文件:
test.hpp
#pragma once
namespace numbers {
typedef float float4;
}
numbers::float4 foo();
void foo1( numbers::float4 );
test.cpp
#include <iostream>
#include "test.hpp"
numbers::float4 foo() {
return 3.14f;
}
void foo1(numbers::float4 f) {
std::cout << f << 'n';
}
还有懒人的SWIG接口文件:
test.i
%module example
%{
#include "test.hpp"
%}
%include "test.hpp"
然后我生成包装器代码并将所有内容编译为共享对象。
$ swig -c++ -lua test.i
$ g++ -I/usr/include/lua5.2 -fPIC -shared test_wrap.cxx test.cpp -o example.so
以下示例脚本运行良好。
test.lua
local example = require"example"
local foo = example.foo
local foo1 = example.foo1
result = foo()
foo1( result )
$ lua test.lua
3.14
相关文章:
- 如何将成员函数作为回调参数传递给需要"typedef-ed"自由函数指针的函数?
- typedef名称与可变模板参数名称一致时出现GCC错误
- 如何对绑定的成员方法进行typedef,然后将该类型用作模板参数
- 有没有一种方法可以使用typedef中的参数名称
- C++:显式调用模板参数的 typedef 的析构函数
- 如何在 C++ 中将 typedef 与类初始值设定项参数一起使用?
- 指向具有 2 个参数的 WINAPI 函数的 Typedef 指针
- 如何使用函数签名的 typedef 作为 std::function 的类型参数
- 如何在 C/C++ 中将 typedef 函数作为参数传递
- 如何从对象内部的 typedef 获取模板参数类型
- C 迭代器从Typedef std :: Map作为模板参数声明
- 将"typedef char IPString[17]"作为参数传递给函数
- Swig 简单类型 typedef 参数
- 如何将方法指针声明为Typedef方法参数
- c++检查模板参数的嵌套typedef以获取其标量基类型
- 以模板类型为参数的模板的typedef
- 如何用模板参数对函数指针进行typedef
- 使用模板参数的typedef不适用于g++
- 推导 typedef'd 函数指针的模板参数
- C++:使用"typedef"定义的类作为参数进行传递