Message134393
| Author |
Steve.Thompson |
| Recipients |
Steve.Thompson |
| Date |
2011年04月25日.16:52:55 |
| SpamBayes Score |
6.4340554e-07 |
| Marked as misclassified |
No |
| Message-id |
<1303750376.54.0.894731507231.issue11920@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Consider the following:
import ctypes
class struct1( ctypes.Structure ):
_pack_ = 1
_fields_ = [
( "first", ctypes.c_uint8, 1 ),
( "second", ctypes.c_uint8, 1 ),
( "third", ctypes.c_uint8, 1 ),
( "fourth", ctypes.c_uint8, 1 ),
( "fifth", ctypes.c_uint8, 1 ),
( "pad", ctypes.c_uint16, 11 ),
]
s1 = struct1()
print ctypes.sizeof( s1 )
class struct2( ctypes.Structure ):
_pack_ = 1
_fields_ = [
( "first", ctypes.c_uint16, 1 ),
( "second", ctypes.c_uint16, 1 ),
( "third", ctypes.c_uint16, 1 ),
( "fourth", ctypes.c_uint16, 1 ),
( "fifth", ctypes.c_uint16, 1 ),
( "pad", ctypes.c_uint16, 11 ),
]
s2 = struct2()
print ctypes.sizeof( s2 )
The output is:
3
2
I'm generating python code from real c code. The compiler I'm using for the real c code packs both of these structures into two bytes. I need a way to make the first example work in python like the compiler without having to modify the source code.
Is this possible? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年04月25日 16:52:56 | Steve.Thompson | set | recipients:
+ Steve.Thompson |
| 2011年04月25日 16:52:56 | Steve.Thompson | set | messageid: <1303750376.54.0.894731507231.issue11920@psf.upfronthosting.co.za> |
| 2011年04月25日 16:52:55 | Steve.Thompson | link | issue11920 messages |
| 2011年04月25日 16:52:55 | Steve.Thompson | create |
|