Re: [AD] GCC 3.4

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> I finally got to compile gcc 3.4 (snapshot 20040107) for Windows and my
> first test of its usability was compiling allegro.

Good idea!  Btw, which Allegro version?

> `-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.

Yes, we need to devise a configure-like test in order to detect the GCC 
version and pass right option.

> src/fli.c: In function `do_fli_256_color':
>
> src/fli.c:319: warning: use of cast expressions as lvalues is deprecated
>
> src/fli.c:333: warning: use of cast expressions as lvalues is deprecated

The only problem under Linux.  Fixed by the attached patch, commited on 
mainline and branch.  With it, I can compile the library in strictwarn mode.

> windres --include-dir include -O coff -o obj/mingw32/alleg/dllver.o -i
> src/win/dllver.rc
>
> windres: src/win/dllver.rc:1: parse error
>
> make: *** [obj/mingw32/alleg/dllver.o] Error 1
>
> (And make dies for the first time. Windres.exe hasn't changed and
> dllver.rc seems to be ok.)

Weird.  Does the problem happen with other versions of GCC?

> src/win/wddbmp.c: In function `create_directdraw2_surface':
>
> src/win/wddbmp.c:243: warning: dereferencing type-punned pointer will
> break strict-aliasing rules

I need the Allegro version here because the code is not the same in the 4.0.x 
series and in the 4.1.x series.

> Even with those errors dibsound.exe, dxwindow.exe, scrsave.exe and
> demo.exe are built and work.
>
> I just tried all the examples and they're working fine.

Great!

> I'll take advantage of this message to inform you that allegro compiled
> successfully with Intel C++ 7.0 (using MSVC6 headers and some of its
> libraries).

Wunderbar!  Would you mind adding a few lines to the MSVC build documentation 
about how to compile Allegro with ICC, when you have some time to kill?

-- 
Eric Botcazou
--- /home/eric/cvs/allegro/src/fli.c	Fri Dec  5 11:30:33 2003
+++ allegro/src/fli.c	Sun Jan 11 19:46:41 2004
@@ -184,20 +184,33 @@
 
 
 /* helpers for reading FLI chunk data */
+#if 0
+/* the "cast expression as lvalue" extension is deprecated in GCC 3.4 */
 #define READ_BYTE_NC(p)    (*((unsigned char *)(p))++)
 #define READ_CHAR_NC(p)    (*((signed char *)(p))++)
+#else
+#define READ_BYTE_NC(p)    (*(unsigned char *)(p)++)
+#define READ_CHAR_NC(p)    (*(signed char *)(p)++)
+#endif
 
-#if (defined ALLEGRO_GCC) && (defined ALLEGRO_I386)
+#if (defined ALLEGRO_GCC) && (defined ALLEGRO_LITTLE_ENDIAN)
 
-/* for gcc on i386 */
+#if 0
+/* the "cast expression as lvalue" extension is deprecated in GCC 3.4 */
 #define READ_WORD_NC(p)    (*((unsigned short *)(p))++)
 #define READ_SHORT_NC(p)   (*((signed short *)(p))++)
 #define READ_ULONG_NC(p)   (*((unsigned long *)(p))++)
 #define READ_LONG_NC(p)    (*((signed long *)(p))++)
+#else
+/* we use the "statement-expression" extension instead */
+#define READ_WORD_NC(p)    ({ unsigned short *__p = (unsigned short *)(p); p+=2; *__p; })
+#define READ_SHORT_NC(p)   ({ signed short *__p = (signed short *)(p); p+=2; *__p; })
+#define READ_ULONG_NC(p)   ({ unsigned long *__p = (unsigned long *)(p); p+=4; *__p; })
+#define READ_LONG_NC(p)    ({ signed long *__p = (signed long *)(p); p+=4; *__p; })
+#endif
 
 #else
 
-/* for other compilers/platforms */
 static unsigned short _fli_read_word_nc(unsigned char **p)
 {
    unsigned short t;
@@ -330,7 +343,7 @@
       if (end > PAL_SIZE)
 	 return;
       else if ((sz -= length * 3) < 0) {
-	 FLI_KLUDGE((char *)p, sz, length * 3);
+	 FLI_KLUDGE(p, sz, length * 3);
       }
 
       fli_pal_dirty_from = MIN(fli_pal_dirty_from, offset);
@@ -396,7 +409,7 @@
 	    if ((curr + size * 2) > bitmap_end)
 	       return;
 	    else if ((sz -= size * 2) < 0) {
-	       FLI_KLUDGE((char *)p, sz, size * 2);
+	       FLI_KLUDGE(p, sz, size * 2);
 	    }
 	    READ_BLOCK_NC(p, curr, size*2);
 	    curr += size*2;
@@ -406,7 +419,7 @@
 	    if ((curr + size * 2) > bitmap_end)
 	       return;
 	    else if ((sz -= 2) < 0) {
-	       FLI_KLUDGE((char *)p, sz, 2);
+	       FLI_KLUDGE(p, sz, 2);
 	    }
 	    READ_RLE_WORD_NC(p, curr, size);
 	    curr += size*2;
@@ -446,7 +459,7 @@
       if (end > PAL_SIZE)
 	 return;
       else if ((sz -= length * 3) < 0) {
-	 FLI_KLUDGE((char *)p, sz, length * 3);
+	 FLI_KLUDGE(p, sz, length * 3);
       }
 
       fli_pal_dirty_from = MIN(fli_pal_dirty_from, offset);
@@ -503,7 +516,7 @@
 	    if ((curr + size) > bitmap_end)
 	       return;
 	    else if ((sz -= size) < 0) {
-	       FLI_KLUDGE((char *)p, sz, size);
+	       FLI_KLUDGE(p, sz, size);
 	    }
 	    READ_BLOCK_NC(p, curr, size);
 	    curr += size;
@@ -513,7 +526,7 @@
 	    if ((curr + size) > bitmap_end)
 	       return;
 	    else if ((sz -= 1) < 0) {
-	       FLI_KLUDGE((char *)p, sz, 1);
+	       FLI_KLUDGE(p, sz, 1);
 	    }
 	    READ_RLE_BYTE_NC(p, curr, size);
 	    curr += size;
@@ -572,7 +585,7 @@
 	       if ((curr + size) > bitmap_end)
 		  return;
 	       else if ((sz -= size) < 0) {
-		  FLI_KLUDGE((char *)p, sz, size);
+		  FLI_KLUDGE(p, sz, size);
 	       }
 	       READ_BLOCK_NC(p, curr, size);
 	       curr += size;
@@ -581,7 +594,7 @@
 	       if ((curr + size) > bitmap_end)
 		  return;
 	       else if ((sz -= 1) < 0) {
-		  FLI_KLUDGE((char *)p, sz, 1);
+		  FLI_KLUDGE(p, sz, 1);
 	       }
 	       READ_RLE_BYTE_NC(p, curr, size);
 	       curr += size;
@@ -600,7 +613,7 @@
 	       if ((curr + size) > bitmap_end)
 		  return;
 	       if ((sz -= size) < 0) {
-		  FLI_KLUDGE((char *)p, sz, size);
+		  FLI_KLUDGE(p, sz, size);
 	       }
 	       READ_BLOCK_NC(p, curr, size);
 	       curr += size;
@@ -609,7 +622,7 @@
 	       if ((curr + size) > bitmap_end)
 		  return;
 	       if ((sz -= 1) < 0) {
-		  FLI_KLUDGE((char *)p, sz, 1);
+		  FLI_KLUDGE(p, sz, 1);
 	       }
 	       READ_RLE_BYTE_NC(p, curr, size);
 	       curr += size;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/