I'm having trouble assigning a two dimensional float array to a pointer-to-pointer-to-float. I'm getting the warning
warning: initialization from incompatible pointer type
The assignment in question is at the bottom of the first code sample. I have changed my syntax around a bit based on stuff I've read on SO, but my problem persists. I'm trying to store data to represent the vertices and faces of a box, so I malloc'd a float** to hold all of the vertices, which worked, and then I malloc'd a float*** to hold a list of faces, where each face is defined by a list of vertices. Finally, I created an intermediary variable face0 which I want to store the list of vertices for a face and then assign that to face[0] like I did with anchors. This assignment does not work.
The assignment in question is at the bottom of the first code sample.
// I first create my list of vertices
// This part works
float **anchors;
int numAnchors = 8;
anchors = (float**)malloc(numAnchors*sizeof(float*));
// anchor0 etc are float arrays of length 3
anchors[0] = anchor0;
anchors[1] = anchor1;
anchors[2] = anchor2;
anchors[3] = anchor3;
anchors[4] = anchor4;
anchors[5] = anchor5;
anchors[6] = anchor6;
anchors[7] = anchor7;
// Now I want to create a list of box faces where
// each face is defined by four vertices.
float ***faces;
int numFaces = 6;
faces = (float***)malloc(numFaces*sizeof(float**));
float **face0 = {anchors[0], anchors[1], anchors[2], anchors[3]};
// warning: initialization from incompatible pointer type [enabled by default]
Based on what I have read here on SO, I have also tried replacing the last line with the following and got the following errors.
float face0[][] = {anchors[0], anchors[1], anchors[2], anchors[3]};
// error: array type has incomplete element type
and
float face0[][3] = {anchors[0], anchors[1], anchors[2], anchors[3]};
// error: incompatible types when initializing type ‘float’ using type ‘float *’
and
// foregoing the intermediary variable entirely
faces[0] = {anchors[0], anchors[1], anchors[2], anchors[3]};
// error: expected expression before ‘{’ token
I have also read the following which argued for an entirely different method of assignment:
conversion of 2D array to pointer-to-pointer
But I cannot even get the toy example to work as it is intended.
EDIT
This project can only use C syntax.