title: 3d matrix dynamic allocation error C2036: 'void *'
body: <p>I have a MPI project and I'm supposed to convert it in cuda.</p>
  
  <p>The problem is simple, the project use this code to allocate 3d matrix of different types.</p>
  
  <pre><code>void ***Matrix3Allocate(Point3 offset, Point3 size, int dataSize){
      void *matrix_data;
      void **matrix_data_ptr;
      void ***matrix;
      int nb_elements = Matrix3GetNbElements(size);
  
      message("Allocate matrix (%d,%d,%d) %d ko (plus pointeurs : %d ko)", 
              size.x, size.y, size.z, nb_elements * dataSize / 1024,
              size.x * ( 1 + size.y ) * sizeof(void*) / 1024);
  
      matrix = (void ***)secure_malloc(size.x * sizeof(void**));
      matrix_data_ptr = (void **)secure_malloc(size.x * size.y * sizeof(void*));
      matrix_data = (void *)secure_malloc(nb_elements * dataSize);
  
      matrix -= offset.x;
      for(int x = offset.x; x &lt; offset.x + size.x; x++)
          matrix[x] = matrix_data_ptr + size.y * (x - offset.x) - offset.y;
  
      for(int x = offset.x; x &lt; offset.x + size.x; x++)
          for(int y = offset.y; y &lt; offset.y + size.y; y++)
              matrix[x][y] = matrix_data +
                      ((x - offset.x) * size.y * size.z +
                  (y - offset.y) * size.z - offset.z) * dataSize;
  
      return matrix;
  }
  </code></pre>
  
  <p>When compiling I have an error C2036: 'void *' unknown size on this part :</p>
  
  <pre><code>matrix[x][y] = matrix_data + ((x - offset.x) * size.y * size.z +
                 (y - offset.y) * size.z - offset.z) * dataSize;
  </code></pre>
  
  <p>I understand why the compiler is screaming but this code was working before (probably with a different compiler) and I would like to change a minimum of code.</p>
  
  <p>Could I make it work with a simple flag?</p>
  
  <p>Is there a minimal modification that could make it compile without error?</p>
  
  <p>The obvious (big) solution is to use c++ templates, but this was a C project so if there is an other (simpler) solution in C...</p>
  
  <p>Thanks.</p>