I'm having strange warnings in Linux. In Visual Studio on Windows, the code compiles and works well but I need to compile it with GCC c90 I get these warnings:
I've initialized the matrix like this:
typedef float mat[4][4];
Now i want to create an array of matrices:
mat MAT_A = { 0 };
mat MAT_B = { 0 };
mat MAT_C = { 0 };
mat *matrices[3] = {MAT_A, MAT_B, MAT_C};
I've declared the function:
void get_input(mat** matrices);
and use it:
get_input(&matrices);
The code is working well but I need to compile it with gcc c90. And I get this warnings:
warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
mat *(*matrices)[3] = {MAT_A, MAT_B, MAT_C};
^~~~~
and
warning: passing argument 1 of ‘get_input’ from incompatible pointer type [-Wincompatible-pointer-types]
flag = get_input(&matrices);
^
Due to this typedef declaration
arrays declared like
are implicitly converted to its first element in this declaration
of the type
float( * )[4]
. But the variable matrices is declared as having the element typefloat ( * )[4][4]
. These types are not compatible.That is in fact you have the following declaration
You should declare the array eother like
In this case the function should be declared like
and called like
or like
in the last case the function is called like
Also the function
get_input
declared likeactually is equivalent to
But in this call of the function
the argument has the type