Incompatible pointer assignment warning

I am writing a function that parses a texture and animation data file and loads it into some global structures that I declared. I get a compiler warning "Assignment from an incompatible pointer type" on a specific line. This is a lot of code, so I'm just going to post the important parts here.

Firstly, I have a structure data type for my animation routines:

    typedef struct {
        unsigned int frames;
        GLuint *tex;
        float *time;
        struct animation *next;
    } animation;

As you can see, the last variable in the structure is a pointer to another default animation when the animation is complete.

Here is the declaration of the download function:

    void LoadTexturePalette(GLuint **texture, animation **anim, const char *filename)

The function loads information into an array of animations, therefore a double pointer.

, , ( ), "".

    fread(tmp, 1, 4, file);
    (*anim)[i].next = &((*anim)[*tmp]);

. , , , , .

+1
1
   typedef struct { /* no tag in definition */
       unsigned int frames;
       GLuint *tex;
       float *time;
       struct animation *next; /* pointer to an undefined structure */
   } animation;

(typedef struct animation { /* ... */ } animation;) "struct animation" undefined. undefined, .

, --- , , typedef: :)

    typedef struct animation { /* tag used in definition */
        unsigned int frames;
        GLuint *tex;
        float *time;
        struct animation *next; /* pointer to another of this structure */
    } animation;
+9

Source: https://habr.com/ru/post/1655916/


All Articles