[ctypes-commit] ctypes/sandbox/bitfields bitsizes.c,1.1,1.2
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-10-13 17:34:27
|
Update of /cvsroot/ctypes/ctypes/sandbox/bitfields In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2455 Modified Files: bitsizes.c Log Message: GCC packs bit fields differently than MSVC. Another struct. Index: bitsizes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/bitfields/bitsizes.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bitsizes.c 13 Oct 2004 17:03:10 -0000 1.1 --- bitsizes.c 13 Oct 2004 17:34:09 -0000 1.2 *************** *** 3,6 **** --- 3,21 ---- * bitfields in structures and unions. */ + /* + On Windows, it prints: + + sizeof(char:4, int:4) = 8 + sizeof(char:4, int:32) = 8 + sizeof(char:4, unsigned char:4) = 1 + + On Linux x86 (Suse, Redhat, x86_64), Mac OS/X, Solaris Sparc: + + sizeof(char:4, int:4) = 4 + sizeof(char:4, int:32) = 8 + sizeof(char:4, unsigned char:4) = 1 + + */ + #include <stdio.h> *************** *** 9,12 **** --- 24,29 ---- typedef struct { char a : 4; unsigned char b: 4; } c4uc4; + typedef struct { char a; char b: 4; int i:4; } a_c4i4; + int main(int argc, char **argv) { *************** *** 14,16 **** --- 31,34 ---- printf("sizeof(char:4, int:32) = %d\n", sizeof(c4i32)); printf("sizeof(char:4, unsigned char:4) = %d\n", sizeof(c4uc4)); + printf("sizeof(char, char:4, int:4) = %d\n", sizeof(a_c4i4)); } |