这是代码段.
typedef struct Lib3dsMesh {
//..
float (*vertices)[3];
//..
}
void* lib3ds_util_realloc_array(void *ptr, int old_size, int new_size, int element_size) {
// Do something here.
return ptr;
}
mesh->vertices = lib3ds_util_realloc_array(mesh->vertices, mesh->nvertices, nvertices, 3 * sizeof(float));
Run Code Online (Sandbox Code Playgroud)
当我在visual c ++中编译此代码时,它返回错误"无法从void*转换为float(*)[3]".
我想知道如何将void*转换为float(*顶点)[3];
可能重复:
C#中的C++联合
#define AVEC3(T) union { T v3[3]; struct { T x,y,z; }; }
#define AMAT3x3(T) union { \
T v9[9], m3x3[3][3]; \
struct { T v3x[3], v3y[3], v3z[3]; }; \
struct { AVec3<T> vecx, vecy, vecz; }; \
struct { AVec3<T> right, up, back; }; \
struct { T xx, xy, xz, yx, yy, yz, zx, zy, zz; }; \
Run Code Online (Sandbox Code Playgroud)
我不知道如何将上面的代码(c ++)转换为c#版本.假设T是双重类型.