I was in the middle of transferring my code for animation into a separate class when I encountered this error. The code was working fine before transferring into a class as I had to add a lot of manual changes to make it work inside of class
Basically I have a class UI, a struct for storing current animations with a pointer that calls a function for rendering every frame.
class UI
{
private:
struct AnimSeq
{ // A struct for intercepting every animation at the same time synced with 60hz timer
void (UI::*renderFunc)(struct AnimSeq *self); // A function that executes every frame of animation. The whole AnimSeq object is considered empty if this pointer equals NULL.
uint8_t step; // Current frame of animation (gets updated with every frame)
uint8_t duration; // Duration in 60 frames per second (interpolated, if FPS is set to less than that)
int16_t offset[2]; // Should be used to offset drawing current animation if whole object moves
};
struct AnimSeq *AnimQueue[4];
void renderAnim_MenuCornerSlide(struct AnimSeq *self); // An example of rendering animation
void UI::HandleAnimation()
{
if (!isEmpty())
{
for (uint8_t i = 0; i < 4; i++)
{
if (AnimQueue[i]->renderFunc != NULL)
{
AnimQueue[i]->renderFunc(AnimQueue[i]); // here's the error
}
}
}
}
My compiler shows an error on the line above that I can't even understand because the message seems to have nothing to do with actual error:
Expression Preceding Parentheses of Apparent Call Must Have (Pointer-To-) Function Type
I tried making AnimQueue not pointer type and encountered a whole lot of new errors. Also tried making all sorts of * and () on that particular line and nothing worked.
Can someone explain what happens here and how to fix it?