Skip to content

Instantly share code, notes, and snippets.

@euphoria
Created October 7, 2014 15:34
Show Gist options
  • Save euphoria/e41259058557efa53876 to your computer and use it in GitHub Desktop.
Save euphoria/e41259058557efa53876 to your computer and use it in GitHub Desktop.
cffi struct copy
ffi.cdef("struct my_struct { int a; int b; };")
first = ffi.new("struct my_struct *")
first.a = 1
first.b = 100
"""
(Pdb) first
<cdata 'struct my_struct *' owning 8 bytes>
(Pdb) second = ffi.new("struct my_struct *", first)
*** TypeError: initializer for ctype 'struct my_struct' must be a list or tuple or dict or struct-cdata, not cdata 'struct my_struct *'
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment