PyDocs

Nav

Generic Operating System Services

CField

ctypes

class · Added in 3.14
  • CField(*args, **kw)
Structure/Union member
Members of CField

b

bit_offset
additional offset in bits (relative to byte_offset); zero for non-bitfields
bit_size
size of this field in bits
byte_offset
offset in bytes of this field.
byte_size
size of this field in bytes

i

is_anonymous
true if this field is anonymous
is_bitfield
true if this is a bitfield

n

name
name of this field

o

offset
offset in bytes of this field (same as byte_offset)

s

size
size in bytes of this field.

t

type
type of this field
1 Example
>>> class Color(Structure):
...     _fields_ = (
...         ('red', c_uint8),
...         ('green', c_uint8),
...         ('blue', c_uint8),
...         ('intense', c_bool, 1),
...         ('blinking', c_bool, 1),
...    )
...
>>> Color.red
<ctypes.CField 'red' type=c_ubyte, ofs=0, size=1>
>>> Color.green.type
<class 'ctypes.c_ubyte'>
>>> Color.blue.byte_offset
2
>>> Color.intense
<ctypes.CField 'intense' type=c_bool, ofs=3, bit_size=1, bit_offset=0>
>>> Color.blinking.bit_offset
1
from the Python docs
See Also
No see-alsos for ctypes/CField
0 Notes
No notes for CField