Mail Archives: djgpp-workers/2004/10/27/11:31:06
2 files in DJGPP CVS version
src/libc/compat/bsd/bcmp.c
src/libc/compat/stdlib/swab.c
uses following construct '((foo *) ptr)++', where foo is either
char or const char and ptr is pointer to void.
This construction generates warning with gcc-3.4.X
gcc ... -c bcmp.c
bcmp.c: In function `bcmp':
bcmp.c:17: warning: use of cast expressions as lvalues is deprecated
bcmp.c:17: warning: use of cast expressions as lvalues is deprecated
make.exe[3]: *** [bcmp.o] Error 1
With gcc-4.0.0 development version the result is error (no more warning).
Introducing temporary char * and const char * variables fixes the problem.
Andris
--- djgpp/src/libc/compat/bsd/bcmp.c~2 1995-08-23 04:56:02.000000000 +0000
+++ djgpp/src/libc/compat/bsd/bcmp.c 2004-10-26 20:27:20.000000000 +0000
@@ -4,8 +4,10 @@
#undef bcmp
int
-bcmp(const void *ptr1, const void *ptr2, int length)
+bcmp(const void *ptr1_, const void *ptr2_, int length)
{
+ const char *ptr1 = ptr1_;
+ const char *ptr2 = ptr2_;
if (ptr1 == ptr2)
return 0;
@@ -14,7 +16,7 @@ bcmp(const void *ptr1, const void *ptr2,
while (length)
{
- if (*((const char *)ptr1)++ != *((const char *)ptr2)++)
+ if (*ptr1++ != *ptr2++)
return length;
length--;
}
--- djgpp/src/libc/compat/stdlib/swab.c~2 1995-10-01 04:41:00.000000000 +0000
+++ djgpp/src/libc/compat/stdlib/swab.c 2004-10-26 20:30:18.000000000 +0000
@@ -2,12 +2,14 @@
#include <stdlib.h>
void
-swab(const void *from, void *to, int n)
+swab(const void *from_, void *to_, int n)
{
unsigned long temp;
+ const char *from = from_;
+ char *to = to_;
n >>= 1; n++;
-#define STEP temp = *((const char *)from)++,*((char *)to)++ = *((const char
*)from)++,*((char *)to)++ = temp
+#define STEP temp = *from++,*to++ = *from++,*to++ = temp
/* round to multiple of 8 */
while ((--n) & 07)
STEP;
- Raw text -