I found problem in structure packing in mingw32ce.
Here is output from wa.c file compiled by mingw32ce :
sizeof(t1) = 12
(t1)offset f2 =4
(t1)offset f3 =8
(t1)offset f4 =9
sizeof(t2) = 16
(t2)offset f2 =4
(t2)offset f3 =12
(t2)offset f4 =13
Output (Visual C) :
sizeof(t1) = 12
(t1)offset f2 =4
(t1)offset f3 =8
(t1)offset f4 =9
sizeof(t2) = 24
(t2)offset f2 =8
(t2)offset f3 =16
(t2)offset f4 =17
When structure doesn't contain long long field everything is OK, but when
structure contain such field
in visual c integer types like (unsigned short) occupies 8 bytes (in mingw32ce
4 bytes).
Is this a bug ?,or is there a compiler (switch / directive ) to walk around
this problem?
Maciek Kaliszewski
----------------------------------------------------------------------
Gra - zostan agentem ABW!
Zobacz >>> http://link.interia.pl/f1ba5
#include <stdio.h>
struct T1 {
unsigned short f1;
int f2;
char f3;
char f4;
};
struct T2 {
unsigned short f1;
long long f2;
char f3;
char f4;
};
int main(int argc,char *argv[]) {
struct T1 t1;
struct T2 t2;
FILE *f;
f=fopen("\\Storage Card\\tmp\\wa\\log.txt","w");
fprintf(f,"sizeof(t1) = %i\n",sizeof(t1));
fprintf(f,"(t1)offset f2 =%i\n",((char*)&t1.f2) - ((char*)&t1.f1));
fprintf(f,"(t1)offset f3 =%i\n",((char*)&t1.f3) - ((char*)&t1.f1));
fprintf(f,"(t1)offset f4 =%i\n",((char*)&t1.f4) - ((char*)&t1.f1));
fprintf(f,"sizeof(t2) = %i\n",sizeof(t2));
fprintf(f,"(t2)offset f2 =%i\n",((char*)&t2.f2) - ((char*)&t2.f1));
fprintf(f,"(t2)offset f3 =%i\n",((char*)&t2.f3) - ((char*)&t2.f1));
fprintf(f,"(t2)offset f4 =%i\n",((char*)&t2.f4) - ((char*)&t2.f1));
fclose(f);
return 0;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel