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
Your type definition should read
typedef struct matrix_t {
int **M;
int nLi;
int nCo;
struct matrix_t *next;
} 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.
Aha, you don't have a struct matrix_t
yet the next
field is declared using a struct tag. This then causes problems whenever the next
field is used.
matrix_t
could be both a struct tag and a type name, as they are in different namespaces, but as it is, your definition starts with...
struct {
not...
struct matrix_t {
In other words, you have an unnamed struct which has a typedef called matrix_t
but you never actually define a struct matrix_t.
Change your struct
definition to this:
typedef struct matrix_t {
int **M;
int nLi;
int nCo;
struct matrix_t *next;
} matrix_t;
Notice the difference?
struct matrix_t
is not the same as typedef ... matrix_t
; they exist in different namespaces; so in your version of the code, the compiler assumes that struct matrix_t *next
refers to a different, incomplete type.