Saturday, 9 March 2013

Passed-by-value struct argument contains uninitialized data

While working on the card game, keep getting this annoying warning: "Passed-by-value struct argument contains uninitialized data" but couldn't work out anything wrong....

Later realised it's complaining about the "tmp" CGPoint variable returned from the other method "getCardPositionWithIndexForPlayer". Checked that method and at the beginning it's just a simple declaration, in the middle there're 2 few different "if" condition checks that assign value to the variable, and then return the value.

CGPoint tmpPoint;
if ((player.position == PlayerPositionLeft) || (player.position == PlayerPositionRight)) {
} else if ((player.position == PlayerPositionBottom) || (player.position == PlayerPositionTop)) {


return tmpPoint;

I guess the compile is complaining that that's no trailing "else" at the end of the last "if" block - in case there's a condition not covered. So I fixed it by changing the 2nd "if" check to "else" only, as if the player is not at left or right position, must be either at bottom or top. Problem solved.

No comments:

Post a Comment