c++ - Spurious/wrong warning, DMC 8.33
- Jean-Pierre H. Dumas (56/56) May 16 2003 I have this happening in several files, and it seems always wrong.
- Walter (6/18) May 16 2003 The warning applies to the function lexically preceding darken_image, no...
- Jean-Pierre H. Dumas (110/113) May 17 2003 The warning appears at the line :
- Walter (6/119) May 17 2003 Looks ok to me, too, but I can't verify it. Can you please send me an
I have this happening in several files, and it seems always wrong. SC 7.5 does not gives this spurious warning. [void darken_image(Viewer *v)] is line 344 Am I missing something ? jp ============================= J:\dev\GraphApp_3.45\src>make -f makefile.dms demos sc -mn -o -WA -f -5 -a4 -I. -L/EXET:NT -L/SU:WINDOWS -L/STUB:WINSTUB.EXE demo\im agine.c graphapp.lib kernel32.lib gdi32.lib user32.lib -odemo\imagine.exe void darken_image(Viewer *v) ^ demo\imagine.c(344) : Warning 12: variable 'struct Colour c' used before set ______________ void darken_image(Viewer *v) { int x, y; Rect r; Colour c; Image *i; Graphics *gw, *gb; double factor = 1.1; if (v->img) { /* modify the image */ i = v->img; if (i->depth == 8) { for (y=0; y < i->cmap_size; y++) { c = i->cmap[y]; c.red /= factor; c.green /= factor; c.blue /= factor; i->cmap[y] = c; } } else for (y=0; y < i->height; y++) for (x=0; x <= i->width; x++) { c = i->data32[y][x]; c.red /= factor; c.green /= factor; c.blue /= factor; i->data32[y][x] = c; } /* update the bitmap and window */ r = get_image_area(i); r = display_area(v->win, r); if (v->bmp) del_bitmap(v->bmp); v->bmp = new_bitmap(v->win, r.width, r.height); gb = get_bitmap_graphics(v->bmp); draw_image(gb, r, i, get_image_area(i)); gw = get_window_graphics(v->win); copy_rect(gw, pt(0,0), gb, get_bitmap_area(v->bmp)); del_graphics(gw); del_graphics(gb); } } _________________
May 16 2003
The warning applies to the function lexically preceding darken_image, not darken_image itself. What does that function look like? "Jean-Pierre H. Dumas" <jeanpierre.dumas freesbee.fr> wrote in message news:1103_1053097033 news.digitalmars.com...I have this happening in several files, and it seems always wrong. SC 7.5 does not gives this spurious warning. [void darken_image(Viewer *v)] is line 344 Am I missing something ? jp ============================= J:\dev\GraphApp_3.45\src>make -f makefile.dms demos sc -mn -o -WA -f -5 -a4 -I. -L/EXET:NT -L/SU:WINDOWS -L/STUB:WINSTUB.EXEdemo\imagine.c graphapp.lib kernel32.lib gdi32.lib user32.lib -odemo\imagine.exe void darken_image(Viewer *v) ^ demo\imagine.c(344) : Warning 12: variable 'struct Colour c' used beforeset
May 16 2003
On Fri, 16 May 2003 08:42:10 -0700, "Walter" <walter digitalmars.com> wrote:The warning applies to the function lexically preceding darken_image, not darken_image itself. What does that function look like?The warning appears at the line : void darken_image(Viewer *v) That's 344 The function before it looks quite OK to me too. Jean-Pierre ___________________________________________________________ void lighten_image(Viewer *v) { int x, y; Rect r; Colour c; Image *i; Graphics *gw, *gb; double factor = 1.1; long max = 255 / factor; if (v->img) { /* modify the image */ i = v->img; if (i->depth == 8) { for (y=0; y < i->cmap_size; y++) { c = i->cmap[y]; if (c.red >= max) c.red = 255; else c.red *= factor; if (c.green >= max) c.green = 255; else c.green *= factor; if (c.blue >= max) c.blue = 255; else c.blue *= factor; i->cmap[y] = c; } } else for (y=0; y < i->height; y++) for (x=0; x <= i->width; x++) { c = i->data32[y][x]; if (c.red >= max) c.red = 255; else c.red *= factor; if (c.green >= max) c.green = 255; else c.green *= factor; if (c.blue >= max) c.blue = 255; else c.blue *= factor; i->data32[y][x] = c; } /* update the bitmap and window */ r = get_image_area(i); r = display_area(v->win, r); if (v->bmp) del_bitmap(v->bmp); v->bmp = new_bitmap(v->win, r.width, r.height); gb = get_bitmap_graphics(v->bmp); draw_image(gb, r, i, get_image_area(i)); gw = get_window_graphics(v->win); copy_rect(gw, pt(0,0), gb, get_bitmap_area(v->bmp)); del_graphics(gw); del_graphics(gb); } } void darken_image(Viewer *v) { int x, y; Rect r; Colour c; Image *i; Graphics *gw, *gb; double factor = 1.1; if (v->img) { /* modify the image */ i = v->img; if (i->depth == 8) { for (y=0; y < i->cmap_size; y++) { c = i->cmap[y]; c.red /= factor; c.green /= factor; c.blue /= factor; i->cmap[y] = c; } } else for (y=0; y < i->height; y++) for (x=0; x <= i->width; x++) { c = i->data32[y][x]; c.red /= factor; c.green /= factor; c.blue /= factor; i->data32[y][x] = c; } /* update the bitmap and window */ r = get_image_area(i); r = display_area(v->win, r); if (v->bmp) del_bitmap(v->bmp); v->bmp = new_bitmap(v->win, r.width, r.height); gb = get_bitmap_graphics(v->bmp); draw_image(gb, r, i, get_image_area(i)); gw = get_window_graphics(v->win); copy_rect(gw, pt(0,0), gb, get_bitmap_area(v->bmp)); del_graphics(gw); del_graphics(gb); } }
May 17 2003
Looks ok to me, too, but I can't verify it. Can you please send me an example I can compile? "Jean-Pierre H. Dumas" <jeanpierre.dumas freesbee.fr> wrote in message news:1103_1053176546 news.digitalmars.com...On Fri, 16 May 2003 08:42:10 -0700, "Walter" <walter digitalmars.com>wrote:notThe warning applies to the function lexically preceding darken_image,darken_image itself. What does that function look like?The warning appears at the line : void darken_image(Viewer *v) That's 344 The function before it looks quite OK to me too. Jean-Pierre ___________________________________________________________ void lighten_image(Viewer *v) { int x, y; Rect r; Colour c; Image *i; Graphics *gw, *gb; double factor = 1.1; long max = 255 / factor; if (v->img) { /* modify the image */ i = v->img; if (i->depth == 8) { for (y=0; y < i->cmap_size; y++) { c = i->cmap[y]; if (c.red >= max) c.red = 255; else c.red *= factor; if (c.green >= max) c.green = 255; else c.green *= factor; if (c.blue >= max) c.blue = 255; else c.blue *= factor; i->cmap[y] = c; } } else for (y=0; y < i->height; y++) for (x=0; x <= i->width; x++) { c = i->data32[y][x]; if (c.red >= max) c.red = 255; else c.red *= factor; if (c.green >= max) c.green = 255; else c.green *= factor; if (c.blue >= max) c.blue = 255; else c.blue *= factor; i->data32[y][x] = c; } /* update the bitmap and window */ r = get_image_area(i); r = display_area(v->win, r); if (v->bmp) del_bitmap(v->bmp); v->bmp = new_bitmap(v->win, r.width, r.height); gb = get_bitmap_graphics(v->bmp); draw_image(gb, r, i, get_image_area(i)); gw = get_window_graphics(v->win); copy_rect(gw, pt(0,0), gb, get_bitmap_area(v->bmp)); del_graphics(gw); del_graphics(gb); } } void darken_image(Viewer *v) { int x, y; Rect r; Colour c; Image *i; Graphics *gw, *gb; double factor = 1.1; if (v->img) { /* modify the image */ i = v->img; if (i->depth == 8) { for (y=0; y < i->cmap_size; y++) { c = i->cmap[y]; c.red /= factor; c.green /= factor; c.blue /= factor; i->cmap[y] = c; } } else for (y=0; y < i->height; y++) for (x=0; x <= i->width; x++) { c = i->data32[y][x]; c.red /= factor; c.green /= factor; c.blue /= factor; i->data32[y][x] = c; } /* update the bitmap and window */ r = get_image_area(i); r = display_area(v->win, r); if (v->bmp) del_bitmap(v->bmp); v->bmp = new_bitmap(v->win, r.width, r.height); gb = get_bitmap_graphics(v->bmp); draw_image(gb, r, i, get_image_area(i)); gw = get_window_graphics(v->win); copy_rect(gw, pt(0,0), gb, get_bitmap_area(v->bmp)); del_graphics(gw); del_graphics(gb); } }
May 17 2003