project-navigation
Personal tools

Author Topic: error: request for member 'data' in something not a structure or union  (Read 7252 times)

Offline criusmac

  • Squad Leader
  • ****
  • Posts: 168
    • View Profile
This compiles:

Code: [Select]
woundList = target->chr.wounds;
index = LIST_Count(woundList);
for (i = 0; i < index; i++) {
wound = (wound_t *)LIST_GetByIdx(woundList, i);
if ((wound->location == WOUND_ARMS) && wound->affectSkill) {
if (wound->treated)
armWounds += wound->value / 2;
else
armWounds += wound->value;
}
woundList = woundList->next;
}
/**< TODO: Value of all arm wounds is now stored in armWounds, do something with it here. */

This is what it used to be:

Code: [Select]
/**< Calculate Head Wounds */
woundList = target->chr.wounds;
while (woundList) {
wound = (wound_t *)woundList.data;
if ((wound->location == WOUND_HEAD) && wound->affectSkill) {
if (wound->treated)
headWounds += wound->value / 2;
else
headWounds += wound->value;
}
woundList = woundList->next;
}
/**< TODO: Value of all head wounds is now stored in headWounds, do something with it here. */

If there a way to access the linked list contents faster than using the functions?

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: error: request for member 'data' in something not a structure or union
« Reply #1 on: September 17, 2009, 08:21:20 pm »
woundList is a pointer no? then use "woundList->" instead of "woundList."

Offline criusmac

  • Squad Leader
  • ****
  • Posts: 168
    • View Profile
Re: error: request for member 'data' in something not a structure or union
« Reply #2 on: September 17, 2009, 08:24:25 pm »
Yup, that was it. I misread the error message. My bad.