Re: [AD] fixed gcc warning |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Sun, 2004-07-18 at 21:01 +0200, Eric Botcazou wrote:
> > The attached patch makes Allegro's C-only version compile with --enable-
> > strict-warn and gcc 3.3.4. Without it, I get this:
> >
> > src/c/cstretch.c: In function `stretch_line15':
> > src/c/cstretch.c:104: warning: use of cast expressions as lvalues is
> > deprecated
> >
> > And some more of that.
>
> My bad, I forgot to check the C-only version.
>
> > After someone confirms there's no problem with it (there'd be no more
> > need at all for the type parameter now, and I'm not too sure what the
> > cast around an lavalue actually does - so I might be overlooking
> > something), I'll commit it.
>
> Without the extension (i.e. by following ISO C), the expression
>
> (unsigned char*) s
>
> is not a lvalue (ISO C99 6.5.4 §4 note 85 :-) so it can't be the destination
> of an assignment.
>
>
> I think this part of the patch is wrong:
>
> -type *s = (type*) sptr; \
> +unsigned char *s = sptr; \
>
> because of
>
> set(d, get(s)); \
>
> where the 'get' can be the dereference operator '*', as in
>
> static void stretch_line15(unsigned long dptr, unsigned char *sptr)
> {
> DECLARE_STRETCHER(unsigned short, sizeof(unsigned short), bmp_write15, *);
> }
>
Oops, yes, and i only tested with 8-bit :| I thought get is a function
call. I'll commit the attached patch instead (and this time actually
taking the time to check all calls of the macros).
--
Elias Pschernig
Index: src/c/cstretch.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/c/cstretch.c,v
retrieving revision 1.10
diff -u -p -r1.10 cstretch.c
--- src/c/cstretch.c 26 Mar 2003 10:27:28 -0000 1.10
+++ src/c/cstretch.c 18 Jul 2004 22:51:50 -0000
@@ -39,10 +39,10 @@ unsigned long d = dptr;
unsigned long dend = d + _al_stretch.dw; \
ASSERT(s); \
ASSERT(d); \
-for (; d < dend; d += (size), (unsigned char*) s += _al_stretch.sinc) { \
+for (; d < dend; d += (size), s = (unsigned char*)s + _al_stretch.sinc) { \
set(d, get(s)); \
if (dd >= 0) \
- (unsigned char*) s += (size), dd += _al_stretch.i2; \
+ s = (unsigned char*)s + (size), dd += _al_stretch.i2; \
else \
dd += _al_stretch.i1; \
}
@@ -137,12 +137,12 @@ unsigned long d = dptr;
unsigned long dend = d + _al_stretch.dw; \
ASSERT(s); \
ASSERT(d); \
-for (; d < dend; d += (size), (unsigned char*) s += _al_stretch.sinc) { \
+for (; d < dend; d += (size), s = (unsigned char*)s + _al_stretch.sinc) { \
unsigned long color = get(s); \
if (color != (mask)) \
set(d, color); \
if (dd >= 0) \
- (unsigned char*) s += (size), dd += _al_stretch.i2; \
+ s = (unsigned char*)s + (size), dd += _al_stretch.i2; \
else \
dd += _al_stretch.i1; \
}