[pypy-dev] Cannot instantiate ctype 'struct *' of unknown size
Amaury Forgeot d'Arc
amauryfa at gmail.com
Wed May 20 11:51:27 CEST 2015
2015-05-20 11:44 GMT+02:00 Yicong Huang <hengha.mao at gmail.com>:
> Hi,
>
> The below is the code we met troubles;
>
> ffi.cdef('''
> struct API {
> struct api_ret* (*pyudf)(char* str);
> };
> ''')
>
> ffi.cdef('''
> struct api_ret {
> char *ret1;
> char *ret2;
> char *ret3;
> };
> ''')
>
> result = ffi.new('struct api_ret*')
>
This code works for me. What's the issue exactly?
>
> At first, we defined struct API with a function pointer that return a
> pointer to struct api_ret.
> And then we defined api_ret, and tried to new the object.
> The problem seems to happen when the function pointer and new structure
> are together.
> The below code had no problems.
>
> ffi.cdef('''
> struct API {
> struct api_ret* (*pyudf)(char* str);
> };
> ''')
>
> ffi.cdef('''
> struct api_ret2 {
> char *ret1;
> char *ret2;
> char *ret3;
> };
> ''')
> #we used different name api_ret2 to work around the issue.
> result = ffi.new('struct api_ret2*')
>
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> https://mail.python.org/mailman/listinfo/pypy-dev
>
>
--
Amaury Forgeot d'Arc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150520/831a5615/attachment-0001.html>
More information about the pypy-dev
mailing list