0
votes

I'm making a small game for a microboard. It's an Arkanoid game. I'm trying to implement a callback in this way:

typedef void    (*TPFN_BEHAVIOUR)(int block_number); 

typedef struct
  {
      int square_number;
      int initial_x;
      int initial_y;
      int final_x;
      int final_y;
      TPFN_BEHAVIOUR behaviour;
}Square;

Square  block[150];

Then I do:

block[i].behaviour = app_DetectCollision_SendLife;

where app_Detect_Collision_SendLife is

void app_DetectCollision_SendLife(int i){

    int initial_x = block[i].final_x - block[i].initial_x - 5;
    int initial_y = block[i].final_y;
    services_Screen_Draw(heart, initial_x, initial_y, 10, 9);
}

I'm getting the error shown in the title in the following line:

 block[special_block].behaviour = app_DetectCollision_SendLife;
2
could you post entire code. [what is special_block?] - amdixon
Where in the code is app_DetectCollision_SendLifedeclared? Is it before the line ` block[special_block].behaviour = app_DetectCollision_SendLife;`? - this
It's just an integer. A way to iterate over the structure array. I can't post all the code because it's huge long. Just ask me what you need and I'll explain to you. - Aldridge1991
I'm not sure if it's before or after because they're in different source files - Aldridge1991
One possibility is that the scope where block[special_block].behaviour = app_DetectCollision_SendLife; occurs has an incorrect declaration of block that is not an array. Check that it isn't something like Square block; - Mark Plotnick

2 Answers

1
votes

One possibility is that the scope where block[special_block].behaviour = app_DetectCollision_SendLife; occurs has an incorrect declaration of block that is not an array. Check that it isn't something like Square block;

THANKS TO

Mark Plotnick

0
votes

Compiles on my system. Must be blocks is not known when you use it. If it's located in a different file, use extern to have the compiler know it.

In C file where blocks is defined:

Square  block[150];

In C file where blocks is used (or in header file):

extern Square  block[150];