K
Karthik
Hello Everybody,
I'm trying to create a packed structure in ctypes (with one 64-bit
element that is bitfielded to 48 bits),
unsuccessfully:
===================================
from ctypes import *
class foo (Structure):
_pack_ = 1
_fields_ = [
("bar", c_ulonglong, 48),
]
print("sizeof(foo) = %d" % sizeof(foo))
===================================
I'm expecting that this should print 6 - however, on my box, it prints
8.
The following piece of C code, when compiled and run, prints 6, which
is correct.
===================================
struct foo {
unsigned long long bar: 48;
};
printf("sizeof(foo) = %d", sizeof(foo));
===================================
So... what am I doing wrong?
Thanks,
Karthik.
I'm trying to create a packed structure in ctypes (with one 64-bit
element that is bitfielded to 48 bits),
unsuccessfully:
===================================
from ctypes import *
class foo (Structure):
_pack_ = 1
_fields_ = [
("bar", c_ulonglong, 48),
]
print("sizeof(foo) = %d" % sizeof(foo))
===================================
I'm expecting that this should print 6 - however, on my box, it prints
8.
The following piece of C code, when compiled and run, prints 6, which
is correct.
===================================
struct foo {
unsigned long long bar: 48;
};
printf("sizeof(foo) = %d", sizeof(foo));
===================================
So... what am I doing wrong?
Thanks,
Karthik.