Overriding existing typedef

20 views
Skip to first unread message

Chiong Ching Lai

unread,
Oct 17, 2017, 9:52:34 PM10/17/17
to python-cffi
Hello,

Is the following the intended behaviour?

In [12]: ffi=cffi.FFI()


In [13]: ffi.new("size_t*")

Out[13]: <cdata 'size_t *' owning 8 bytes>


In [14]: ffi.cdef("typedef char size_t;", override=True)


In [15]: ffi.new("size_t*")

Out[15]: <cdata 'size_t *' owning 8 bytes>


ffi2=cffi.FFI()


In [7]: ffi2.cdef("typedef char size_t;")


In [8]: ffi2.new("size_t*")

Out[8]: <cdata 'char *' owning 1 bytes>


Regards,
Chiong

Armin Rigo

unread,
Dec 29, 2018, 12:21:24 PM12/29/18
to pytho...@googlegroups.com
Hi,

On Wed, 18 Oct 2017 at 03:52, Chiong Ching Lai <chion...@gmail.com> wrote:
> In [12]: ffi=cffi.FFI()
> In [13]: ffi.new("size_t*")
> In [14]: ffi.cdef("typedef char size_t;", override=True)
> In [15]: ffi.new("size_t*")
> Out[15]: <cdata 'size_t *' owning 8 bytes>
>
> ffi2=cffi.FFI()
> In [7]: ffi2.cdef("typedef char size_t;")
> In [8]: ffi2.new("size_t*")
> Out[8]: <cdata 'char *' owning 1 bytes>

Sorry, replying to a one-year-old mail.

This is a bug; I've opened
https://bitbucket.org/cffi/cffi/issues/397/overriding-standard-type-names-has-no
. Likely, it should complain that you can't override a standard type
like "size_t" after you have used it. It's unclear if it's useful to
let you override it anyway even with ``override=True``. Thanks for
the report!


A bientôt,

Armin.
Reply all
Reply to author
Forward
0 new messages