typedef of fixed length array cannot deal with [...]

91 views
Skip to first unread message

Sarvi Shanmugham

unread,
Sep 28, 2012, 6:35:11 PM9/28/12
to pytho...@googlegroups.com

I have the following in my library
#define FIXED_LEN_STR 255
typedef char fixed_len_str_t[FIXED_LEN_STR];

In my cdef("""
#define FIXED_LEN_STR ...   // This works
typedef char fixed_len_str_t[...];   // this does not work
""")  

Is my only choice to explicitly do the following? Is there a better way of doing this? 
typedef char fixed_len_str_t[255];

Also, the Error message when it hits the problem is as follows, which doesn't tell me where the error is. 
For now I understand this generally means and where to look. But for people with no experience with CFFI,
 it would be help full to provide some context or line numbers or something to help locate the point the cdef where this error happens.

File "/ws/sarvi-sjc/skunkworks/tmproot/lib/python2.6/site-packages/cffi-0.4-py2.6-linux-x86_64.egg/cffi/api.py", line 84, in cdef
    self._parser.parse(csource, override=override)
  File "/ws/sarvi-sjc/skunkworks/tmproot/lib/python2.6/site-packages/cffi-0.4-py2.6-linux-x86_64.egg/cffi/cparser.py", line 100, in parse
    self._internal_parse(csource)
  File "/ws/sarvi-sjc/skunkworks/tmproot/lib/python2.6/site-packages/cffi-0.4-py2.6-linux-x86_64.egg/cffi/cparser.py", line 137, in _internal_parse
    realtype = self._get_type(decl.type, name=decl.name)
  File "/ws/sarvi-sjc/skunkworks/tmproot/lib/python2.6/site-packages/cffi-0.4-py2.6-linux-x86_64.egg/cffi/cparser.py", line 222, in _get_type
    typenode.dim, partial_length_ok=partial_length_ok)
  File "/ws/sarvi-sjc/skunkworks/tmproot/lib/python2.6/site-packages/cffi-0.4-py2.6-linux-x86_64.egg/cffi/cparser.py", line 446, in _parse_constant
    raise api.FFIError("unsupported non-constant or "
cffi.api.FFIError: unsupported non-constant or not immediately constant expression

Thanks,
Sarvi

Sarvi Shanmugham

unread,
Oct 4, 2012, 4:15:52 AM10/4/12
to pytho...@googlegroups.com
I have always got quick responses so far, but haven't seen any for my recent questions.

Are these dumb questions, possibly? Or maybe too many questions :-))

I have always tried multiple routes at debugging and googling for answers before asking these questions.
And from what I can tell, all the questions I have asked so far, bar 1 which ended being a bug in my library, ended in either a bug fix or document update.

I hope this is just a case of people being too busy. :-))

Sarvi

Armin Rigo

unread,
Oct 4, 2012, 7:36:33 AM10/4/12
to pytho...@googlegroups.com
Hi,

On Thu, Oct 4, 2012 at 10:15 AM, Sarvi Shanmugham <sarv...@gmail.com> wrote:
> I hope this is just a case of people being too busy. :-))

Yes, exactly :-) Your questions are very useful, I have to thank you
for them. They end up in good suggestions for improvements of CFFI.
I'll come back to your recent questions, but right now I'm at PyCon ZA
(South Africa) :-)


A bientôt,

Armin.

Sarvi Shanmugham

unread,
Oct 4, 2012, 3:38:32 PM10/4/12
to pytho...@googlegroups.com, ar...@tunes.org
I noticed that
char my_array_variable[...];  // Does not work

But the following works
char my_array_variable[];  // This works

The original header files has
#define XYZ_LEN 255
char my_array_variable[XYZ_LEN];


Thx,
Sarvi

Armin Rigo

unread,
Oct 28, 2012, 4:44:07 AM10/28/12
to pytho...@googlegroups.com
Hi,

On Thu, Oct 4, 2012 at 9:38 PM, Sarvi Shanmugham <sarv...@gmail.com> wrote:
> I noticed that
> char my_array_variable[...]; // Does not work
>
> But the following works
> char my_array_variable[]; // This works

I fixed this use case to make the two declarations identical (3bb5d49c0c00).


A bientôt,

Armin.

Sarvi Shanmugham

unread,
Oct 28, 2012, 1:33:13 PM10/28/12
to pytho...@googlegroups.com, ar...@tunes.org
awesome. thanks
Reply all
Reply to author
Forward
0 new messages