Below are definitions for 2 structs, then a short method body that uses them. I don't understand why the compiler throws the error:
physics.c:95: error: incompatible types in assignment
cpBody
and cpSpace
are types from an external library, which isn't part of the problem.
typedef struct gameBody gameBody;
struct gameBody
{
cpBody *body;
int numberOfShapes;
cpShape *arrayOfShapes; //This stores an array of pointers to Shapes
};
//Struct that stores the cpSpace object and the array of pointers to the body objects
typedef struct gameSpace gameSpace;
struct gameSpace
{
cpSpace *space;
int numberOfObjects;
gameBody *arrayOfObjects; //This stores an array of gameBodys
};
void physicsAddBody(gameSpace *space, gameBody *body, int objectIndex)
{
gameBody *array = space -> arrayOfObjects;
array[objectIndex] = body; //THIS IS WHERE THE ERROR IS THROWN
}