Skip to content

How limited is ffi.addressof()? #163

Answered by arigo
AimForNaN asked this question in Q&A
Discussion options

You must be logged in to vote

The type of format_context is 'struct AVFormatContext *', that is, it is already a pointer to the struct. Are you trying to get the address of that pointer, i.e. a pointer-to-pointer?

ffi.addressof() only works on things that have known C-level addresses. The format_context Python variable is a Python object that internally points to that struct, but you can't take its own address because that pointer itself is not C-level data. Think about Python objects as living in a separate world, somewhere else than all the C data that cffi lets you manipulate. You can't get the address of a Python object without using some hacks that are specific to an implementation, say CPython, and these hacks w…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AimForNaN
Comment options

Answer selected by AimForNaN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants