www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Spurious/wrong warning, DMC 8.33

↑ ↓ ← Jean-Pierre H. Dumas <jeanpierre.dumas freesbee.fr> writes:
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
↑ ↓ "Walter" <walter digitalmars.com> writes:
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.EXE

 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

May 16 2003
↑ ↓ Jean-Pierre H. Dumas <jeanpierre.dumas freesbee.fr> writes:
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
↑ ↓ → "Walter" <walter digitalmars.com> writes:
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>

 The 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