[Scummvm-devel] Problem with alignement with GCC

Lionel Ulmer lionel.ulmer at free.fr
Sat Nov 10 03:12:02 CET 2001


> Now, I am going to see why the sound does not work on the iPAQ !

It was again an alignement problem :-) 

The ARM version of GCC has a bad habit of aligning on a 4 bytes boundary all
structures, even the one only containing fields of size < 4 (this because
some ARM architectures do NOT have a load byte instruction).

So let's fix that in sound.cpp with the attached patch (who, of course,
depends on the previous one).

Ludvig, as you must know the source code better than me ( :-) ), do you know
any other part of the code where you directly map some data to a structure
and that would need packing to be sure to work on all compilers ?

     Lionel (who can't wait for iMUSE to also have music on 
             his GameBoyAdv^H^H^H^H^H^H^H^HiPAQ :-) )

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.5
diff -u -r1.5 sound.cpp
--- sound.cpp	2001/11/06 20:25:08	1.5
+++ sound.cpp	2001/11/10 11:05:34
@@ -297,10 +297,12 @@
 	_sfxFile = openSfxFile();
 }
 
+#pragma START_PACK_STRUCTS
 struct VOCHeader {
 	byte id[19];
 	byte extra[7];
-};
+} GCC_PACK;
+#pragma END_PACK_STRUCTS
 
 static const char VALID_VOC_ID[] = "Creative Voice File";
 static const char VALID_VOC_VERSION[] = "";
@@ -354,4 +356,4 @@
 
 void *Scumm::openSfxFile() {
 	return fopen("monster.sou", "rb");
-}
\ No newline at end of file
+}


More information about the Scummvm-devel mailing list