0

I have a matrix data type and a function with a formal parameter of matrix type. Since the function will not modify its parameter I use a const qualifier:

typedef int Matrix[2][2];

static void Foo(const Matrix A)
{
    ...
}

When I call this function it seems like I need to cast the actual parameter:

Matrix A;
...
Foo((const int (*)[2]) A);

Without the cast the compiler I use (GCC) will issue a warning:

warning: pointers to arrays with different qualifiers are incompatible in ISO C [-Wpedantic]

Is there a different way to approach the problem so that the cast is not necessary?

August Karlstrom
  • 10,773
  • 7
  • 38
  • 60

0 Answers0