[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] fixed: compiling img2png



Hello.

gcc34 -I/usr/include -I/usr/include -O2 -Wall   -c -o img2png.o img2png.c
img2png.c: In function `main':
img2png.c:112: warning: use of cast expressions as lvalues is deprecated

In GCC 4, use of cast expressions as lvalues (e.g. with ++) is not supported anymore. But most of such code can be easily fixed.

I made a quick patch to get imgtools compiling with GCC 4. However, I didn't test the resulting executable because I don't have the required libraries for linking it. It may work as expected: just try it.

I use GCC 4.2.1, running on Cygwin, and producing executables for MiNT.
It is available here:
http://vincent.riviere.free.fr/soft/m68k-atari-mint/

Hope this will help.

Vincent Riviere
diff -aurN imgtools/img2png/img2png.c imgtools.new/img2png/img2png.c
--- imgtools/img2png/img2png.c	2007-08-21 11:38:35.000000000 +0200
+++ imgtools.new/img2png/img2png.c	2007-08-26 10:03:05.390625000 +0200
@@ -115,7 +115,7 @@
 
   if (header.ih.headlen >= 11)
   {
-    FGETL(&input.pub, count); *((unsigned long *)p)++ = count;
+    FGETL(&input.pub, count); *((unsigned long *)p) = count; p += 2;
     FGETW(&input.pub, temp); *p++ = temp;
 
     if (count == MKVAL('T','I','M','G'))
diff -aurN imgtools/img2png/imgcodec.h imgtools.new/img2png/imgcodec.h
--- imgtools/img2png/imgcodec.h	1998-05-22 13:33:26.000000000 +0200
+++ imgtools.new/img2png/imgcodec.h	2007-08-26 09:56:07.828125000 +0200
@@ -93,10 +93,10 @@
 
 #define FGETW(fp, dest)   \
   MAKESTMT( if (--(fp)->bytes_left < 0) (*(fp)->data_func)(fp); \
-	    dest = *((unsigned char *)(fp)->pbuf)++; \
+	    dest = *((unsigned char *)(fp)->pbuf); (fp)->pbuf++;\
 	    dest <<= 8; \
 	    if (--(fp)->bytes_left < 0) (*(fp)->data_func)(fp); \
-	    dest |= *((unsigned char *)(fp)->pbuf)++; )
+	    dest |= *((unsigned char *)(fp)->pbuf); (fp)->pbuf++; )
 
 #define FPUTW(fp, wd)   \
   MAKESTMT( *(fp)->pbuf++ = (char)(wd >> 8); \
@@ -107,16 +107,16 @@
 
 #define FGETL(fp, dest)   \
   MAKESTMT( if (--(fp)->bytes_left < 0) (*(fp)->data_func)(fp); \
-	    dest = *((unsigned char *)(fp)->pbuf)++; \
+	    dest = *((unsigned char *)(fp)->pbuf); (fp)->pbuf++; \
 	    dest <<= 8; \
 	    if (--(fp)->bytes_left < 0) (*(fp)->data_func)(fp); \
-	    dest |= *((unsigned char *)(fp)->pbuf)++; \
+	    dest |= *((unsigned char *)(fp)->pbuf); (fp)->pbuf++; \
 	    dest <<= 8; \
 	    if (--(fp)->bytes_left < 0) (*(fp)->data_func)(fp); \
-	    dest |= *((unsigned char *)(fp)->pbuf)++; \
+	    dest |= *((unsigned char *)(fp)->pbuf); (fp)->pbuf++; \
 	    dest <<= 8; \
 	    if (--(fp)->bytes_left < 0) (*(fp)->data_func)(fp); \
-	    dest |= *((unsigned char *)(fp)->pbuf)++; )
+	    dest |= *((unsigned char *)(fp)->pbuf); (fp)->pbuf++; )
 
 /* Prototypes for public library functions. */