The following code fragment reports 2 warnings - both dx and dy are reported {Variable 'dy' was set but never used "loc_t dy = 0;"}. Before I added the "= 0;" to these the warnings were reporting that the values might be used before initialized, but now if I remove the "= 0" is remains "set but never used". Quite confusing to me. I also changed from my typedefs (loc_t) back to int and this did not affect the warnings. And point_t is another typedef of a pair of loc_t.
The code runs correctly, but I always aim for a zero-warnings.
void ThickLine(point_t origin, point_t p)
{
double angleN = 0;
loc_t dy = 0;
loc_t dx = 0;
int thickness = 0;
point_t s = { 0, 0 };
point_t e = { 0, 0 };
lcd.line(origin,p, rgb);
INFO(" End @ (%3d,%3d) - (%3d,%3d) [%d]", origin.x, origin.y, p.x, p.y, pensize);
#define PI 3.14159
dy = p.y - origin.y;
dx = p.x - origin.x;
INFO("delta (%+3d,%+3d)", dx,dy);
angleN = atan2((double)(p.y-origin.y), (double)(p.x-origin.x));
thickness = pensize;
for (int l=-thickness; l<=thickness; l++) {
s.x = origin.x + l * cos(angleN+PI/2);
s.y = origin.y + l * sin(angleN+PI/2);
e.x = p.x + l * cos(angleN+PI/2);
e.y = p.y + l * sin(angleN+PI/2);
lcd.line(s, e, rgb);
INFO(" %+d @ (%3d,%3d) - (%3d,%3d) a:%+3.2f:%+3.2f",
l, s.x,s.y, e.x,e.y, angleN, angleN+PI/2);
}
}
The following code fragment reports 2 warnings - both dx and dy are reported {Variable 'dy' was set but never used "loc_t dy = 0;"}. Before I added the "= 0;" to these the warnings were reporting that the values might be used before initialized, but now if I remove the "= 0" is remains "set but never used". Quite confusing to me. I also changed from my typedefs (loc_t) back to int and this did not affect the warnings. And point_t is another typedef of a pair of loc_t.
The code runs correctly, but I always aim for a zero-warnings.
Any suggestions?