I have used this exact code numerous times in the past weeks, and it has always worked flawlessly.
Code:
typedef struct _LLNode
{
int x;
int y;
int z;
int dx;
int dy;
int dz;
struct _LLNode *next;
} LLNode;
typedef struct _List
{
LLNode *head;
} List;
void addToFront(List *list, int x, int y, int z, int dx, int dy, int dz);
#define FOREVER 1
int main() {
List list = {NULL};
addToFront(&list, 100, 60, 10, -1, 1, -1 );
addToFront(&list, 200, 110, 5, -1, 1, 1);
addToFront(&list, 30, 30, 1, 1, 1, 1);
REG_DISPCTL = MODE4 | BG2_ENABLE;
PALETTE[252] = BLACK;
PALETTE[253] = BLUE;
PALETTE[254] = YELLOW;
PALETTE[255] = RED;
while (FOREVER) {
LLNode *hd;
hd = list->head; // ERROR HERE
for(int i = 0; i < 3; i++){
hd->y = hd->y + hd->dy;
hd->x = hd->x + hd->dx;
hd->z = hd->z + hd->dz;
if(hd->y < 0)
{
hd->y = 0;
hd->dy = -hd->dy;
}
if(hd->y>159 - hd->z)
{
hd->y = 159 - hd->z;
hd->dy = -hd->dy;
}
if(hd->x < 0)
{
hd->x = 0;
hd->x = -hd->x;
}
if(hd->x>239 - hd->z)
{
hd->x = 239 - hd->z;
hd->dx = -hd->dx;
}
if(hd->z < 0)
{
hd->z = 0;
hd->dz = -hd->dz;
}
if(hd->z > 10)
{
hd->z = 10;
hd->dz = -hd->dz;
}
hd = hd->next;
}
}
}
I am getting my error with "hd = list->head;"
As you can see, I'm using this pointer to traverse through the linked list. Every iteration, it updates with hd=hd->next;
I am getting an error however. My compiler is telling me:
error: invalid type argument of `->'
However, the code seems valid to me, as I have used this method before. Any idea why I am getting an invalid type error?
---
In addition, my IDE is applying the appropriate colors to all items, as it is recognizing the links as valid.