预计'结构matrix_t *“,但参数的类型为”结构matrix_t *“?_?没有不同 [英] expected ‘struct matrix_t *’ but argument is of type ‘struct matrix_t *’ ?_? no difference
本文介绍了预计'结构matrix_t *“,但参数的类型为”结构matrix_t *“?_?没有不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
main.c:78:25: erreur: assignment from incompatible pointer type [-Werror]
main.c:81:9: erreur: passing argument 2 of ‘matrix_multiply’ from incompatible pointer type [-Werror]
main.c:6:11: note: expected ‘struct matrix_t *’ but argument is of type ‘struct matrix_t *’
6号线是matrix_multiply功能
line 6 is the matrix_multiply function
这是我的code这开始于第74行
here is my code which begin at line 74
matrix_t *m;
matrix_t *first = matrix_reader_next(reader);
matrix_t *previous = first;
while ( (m = matrix_reader_next(reader))) {
previous->next = m;
previous = m;
}
matrix_t *result = matrix_multiply(first,first->next);
和这里是我的函数原型和结构
and here are my function prototypes and structure
typedef struct {
int **M;
int nLi;
int nCo;
struct matrix_t *next;
} matrix_t;
matrix_t* matrix_multiply(matrix_t* first, matrix_t*second);
matrix_t* matrix_reader_next(matrix_reader_t *r);
我真不明白这些错误消息。请帮我:)
I really don't understand these error message. Please help me :)
推荐答案
您的类型定义应该阅读
typedef struct matrix_t {
int **M;
int nLi;
int nCo;
struct matrix_t *next;
} matrix_t;
否则,键入 matrix_t
指的是完整的,但不愿透露姓名的结构类型,而结构matrix_t
指的是不同的命名但不完整的结构类型,你永远无法定义。
Otherwise, the type matrix_t
refers to a complete but unnamed structure type, whereas struct matrix_t
refers to a different, named but incomplete structure type which you never define.
这篇关于预计'结构matrix_t *“,但参数的类型为”结构matrix_t *“?_?没有不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文