DMK
DMK

Reputation: 53

Warning C4047 : 'int **' differs in level of indirection from 'int[2][4]'

I'm getting this warning and scratching my head about why. I found many thread here that address this warning in VS 2017 compiler, but not this particular combination: why isn't int** the same level of indirection as int[X][Y]?

Here's a distilled down example that generates the warning:

void testfunc(int ** input, int ** output) {

  /*
  * Do something
  */

}


int main()
{


  int   firstvar[2][4];
  int   secondvar[2][4];

  testfunc(firstvar, secondvar);

}

I get:

testcode.c(46): warning C4047: 'function': 'int **' differs in levels of indirection from 'int [2][4]'

Any thoughts on why this would be or how to fix it much appreciated.

Upvotes: 3

Views: 1580

Answers (1)

user2962885
user2962885

Reputation: 111

void testfunc(int input[][4], int output[][4])

would be a better way to pass this. Please note int ** seems to indicate it is an array of int *, which it is not.

void onedimension_testfunc(int *odinput, int *odoutput)
{
     ...
}

int main ()
{
      int odfirst[4], odsecond[4];
      onedimention_testfunc(odfirst, odsecond);
}

In one dimension the above code works fine. Thats because odinput/odoutput in the above code points to an integer array. But not for multiple dimensions.

Upvotes: 2

Related Questions