- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 33.3k
 
Closed
Labels
Description
below example is simple and can be reproduced.
from ctypes import Structure,Union
from ctypes import alignment,sizeof
from ctypes import c_int8,c_int16,c_int32,c_int64
from ctypes import c_uint8,c_uint16,c_uint32,c_uint64
class sub_type(Structure):
    _fields_ = [
    ('a',c_uint8,4),
    ('b',c_uint8,4),
    ('c',c_uint16,10),
    ('d',c_uint16,10),
    ('e',c_uint8,1),
    ('f',c_uint8,1),
    ('g',c_uint8,1),
    ]
class main_type(Union):
    byte_length = sizeof(sub_type)
    _fields_ = [
                ("data",    sub_type),
                ("asbytes",  c_uint8*byte_length),
    ]
a=main_type(data=sub_type(e=1,f=1,g=1))
print(list(a.asbytes))
#on windows, print value is correct
#[0, 0, 0, 0, 0, 0, 7, 0]
#on linux, the value is wrong at all. the length is correct, but value is wrong.
#[0, 0, 0, 0, 0, 0]