Помогите разобраться с размерами, уже всю голову сломал.
Есть структура:
class AtaCmd(ctypes.Structure): _fields_ = [ ('opcode', ctypes.c_ubyte), ('protocol', ctypes.c_ubyte), ('flags', ctypes.c_ubyte), ('featuresl', ctypes.c_ubyte), ('featuresh', ctypes.c_ubyte), ('sector_countl', ctypes.c_ubyte), ('sector_counth', ctypes.c_ubyte), ('lba_lowl', ctypes.c_ubyte), ('lba_lowh', ctypes.c_ubyte), ('lba_midl', ctypes.c_ubyte), ('lba_midh', ctypes.c_ubyte), ('lba_highl', ctypes.c_ubyte), ('lba_highh', ctypes.c_ubyte), ('device', ctypes.c_ubyte), ('command', ctypes.c_ubyte), ('control', ctypes.c_ubyte)]
ctypes.sizeof(AtaCmd) возвращает 16, как и должно быть. Меняю пару ubytes (features) на ushort
class AtaCmd(ctypes.Structure): _fields_ = [ ('opcode', ctypes.c_ubyte), ('protocol', ctypes.c_ubyte), ('flags', ctypes.c_ubyte), ('features', ctypes.c_ushort), ('sector_countl', ctypes.c_ubyte), ('sector_counth', ctypes.c_ubyte), ('lba_lowl', ctypes.c_ubyte), ('lba_lowh', ctypes.c_ubyte), ('lba_midl', ctypes.c_ubyte), ('lba_midh', ctypes.c_ubyte), ('lba_highl', ctypes.c_ubyte), ('lba_highh', ctypes.c_ubyte), ('device', ctypes.c_ubyte), ('command', ctypes.c_ubyte), ('control', ctypes.c_ubyte)]
Теперь ctypes.sizeof(AtaCmd) возвращает 18. С какого? Ведь:
ctypes.sizeof(ctypes.c_ubyte) = 1
ctypes.sizeof(ctypes.c_ushort) = 2
В чем проблема?