I'm writing a function that parses a file with texture and animation data and loads it into some global structs I have declared. I get the compiler warning "Assignment from incompatible pointer type" on a particular line. It's a lot of code, so I'm just going to post the important parts here.
First, I have a struct datatype for my animation routines, as follows:
typedef struct {
unsigned int frames;
GLuint *tex;
float *time;
struct animation *next;
} animation;
As you can see, the last variable in the struct is a pointer to another animation to default to when the animation is completed.
Here is the declaration of the loading function:
void LoadTexturePalette(GLuint **texture, animation **anim, const char *filename)
The function loads information into an array of animations, hence the double pointer.
At the very end of loading each animation, an integer is pulled from the file that indicates which animation (out of the ones that are loaded) to which the "next" pointer will point.
fread(tmp, 1, 4, file);
(*anim)[i].next = &((*anim)[*tmp]);
On the last line, I get the compiler warning. I'm not yet using that variable, so I don't know if the warning is an issue, but I get the feeling that my syntax or my approach may be incorrect in setting that variable.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…