gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > warning ignoring #pragma pack(x)

#7841 - Gordon - Thu Jun 26, 2003 1:35 pm

Dear Developer
Are there any replace ment of #pragma pack(push, 1) and #pragma pack(pop)?

eg.
Code:
#parama pack(push, 1)
 
  typedef sturct .. {
  } .., .. ;

  ..

  typedef sturct .. {
  } .., .. ;
 
  #pragma pack(pop)


Bye now!

#7845 - Paul Shirley - Thu Jun 26, 2003 3:41 pm

removed

Last edited by Paul Shirley on Sun Mar 28, 2004 10:02 pm; edited 1 time in total

#7877 - Gordon - Fri Jun 27, 2003 8:56 am

I have try the follwoing
Code:
typedef struct tagAttribute
{
   char c;  // 1 byte
   short s;   // 2 bytes              
} Attribute __attribute__ ((packed));

or

Code:
typedef struct tagAttribute
{
   char c;   // 1 byte
   short s;   // 2 byes                
} Attribute __attribute__ ((aligned(1)));

For sure it works in Windows, but it doesn't work in GBA

sizeof(Attriabute) allway equal to 4, it should be 3
any help or there is a bug in devkitadv

#7878 - Paul Shirley - Fri Jun 27, 2003 10:17 am

removed

Last edited by Paul Shirley on Sun Mar 28, 2004 10:02 pm; edited 1 time in total

#7905 - Gordon - Sat Jun 28, 2003 2:37 am

The thing you said may be ture for Windows apps.. or Linux apps..,
try it yourself, then you will see what happy in the GBA.

when try it, it will give you these:
Windows (3bytes ), Linux (3bytes) but GBA Allway (4bytes)

If you want the answer, I will give you later on!