Hi all,

I have an incompatible pointer type problem.I am using Dev-Cpp and I am trying to intergrate some functions to a large project in C (mpeg2 decoder) and I am stuck here trying many variations to solve it:

//global.h
void transpose_mat _ANSI_ARGS_((double *matA[], double *matB[], int N));
//declaration in the file where function is
void transpose_mat _ANSI_ARGS_((double *matA[],double *matB[], int N));
//function
void transpose_mat(matA, matB, N)
double *matA[]; 
double *matB[];
int N;
{
     
   
     printf("\n TRAnSPOSE MATRIX = \n");
     
     int i,j;
  for (i=0;i<N;i++){
      for (j=i;j<N;j++) {
          matB[j][i] = matA[i][j];
          matB[i][j] = matA[j][i];
          
          } 
      }
          
          for (i=0;i<N;i++){
      for (j=0;j<N;j++) {
     printf(" %d ",matB[i][j]);
     }
     printf("\n");
     }


}    


//where the above function is used:

void DCTcoeff_2x2(block)
short *block;
  {    

double D_2[4][4] = {0.5,   0.4619,    0,     -0.1913,
                    0,     0.1913,   0.5,    0.4619,
                    0.5,  -0.4619,    0,      0.1913,
                    0,     0.1913,   -0.5,    0.4619};
                 
double *D_3[4];  
\\......
transpose_mat(D_2, D_3, 4); /*passing arg 1 from incompatible pointer type.

I would appreciate any help. Thank you for considering my question.

try changing double *matA[] to double matA[][4]

A two dimensional array is not a compatible type with an array of pointers. When you pass a multi-dimensional array to a function, the first dimension is converted to a pointer:

int[2] becomes int*
int[2][4] becomes int(*)[4]
int[2][4][6] becomes int(*)[4][6]

To properly pass D_2, transpose_mat has to expect either double (*matA)[4] or double *matA[][4] Also, why are you using K&R style functions? Those went out of style twenty years ago.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.