c#与c++间传递数组的问题 (SWIG)
巴拉莱卡 2008-05-10 04:36:59 通过swig作中转的
我看使用手册上介绍如果传数组的话要先转成 lvalue,
用typedef 定义了了一个数组。
typedef double vec2d[2];
/***************************
33.8.5 Lvalues
When generating wrapper code, it is necessary to emit datatypes that can be used on the left-hand side of an assignment operator
(an lvalue). However, not all C datatypes can be used in this way---especially arrays and const-qualified types. To generate a
type that can be used as an lvalue, use the following function:
SwigType *SwigType_ltype(SwigType *ty)
Converts type ty to a type that can be used as an lvalue in assignment. The resulting type is stripped of qualifiers and arrays
are converted to a pointers.
The creation of lvalues is fully aware of typedef and other aspects of the type system. Therefore, the creation of an lvalue may
result in unexpected results. Here are a few examples:
typedef double Matrix4[4][4];
Matrix4 x; // type = 'Matrix4', ltype='p.a(4).double'
***************************/
但是不知道为什么,转出来都是SWIGTYPE_P*.cs的类,无法使用的。
但是typedef struct/double 都可以。
在.i文件里面都补完还是不行, 有谁能够提供一个成功的例子么?