【发布时间】:2014-07-07 20:49:42
【问题描述】:
我在编译我的项目时收到此错误。
error: incompatible types when assigning to type ‘Matrix4’ from type ‘double (*)[4]’
我的结构是这样的:
typedef struct testtest {
Matrix4 tMat;
} test;
使用全局变量:
typedef double Matrix4[4][4];
现在,我在程序内部为结构的相关参数分配一个参数,如下所示:
test *newNode;
newNode = (test *)malloc(sizeof(test));
Matrix4 transformMatrix;
//inizializing the matrix....
//...
newNode->tMat = transformMatrix; //<----HERE is the ERROR
如果我把结构改成这样:
typedef struct testtest {
double tMat[4][4];
} test;
我收到类似的错误:
error: incompatible types when assigning to type ‘double[4][4]’ from type ‘double (*)[4]’
请问有人知道我哪里错了吗?非常感谢你:-)
【问题讨论】:
-
给我们
newNode的结构怎么样。 -
你到底想用“typedef double Matrix4[4][4];”实现什么? typedef 用于定义新类型。
标签: c pointers matrix struct typedef