Using C struct in Python** corrected
Fredrik Lundh
fredrik at pythonware.com
Wed Jun 7 17:54:53 EDT 2006
Sudheer Gupta wrote:
> I am having trouble using C struct in python. Hope anyone can help me
> out ...
>
> Say, I have my C struct as
>
> typedef struct call
> {
> struct call *next;
> // .....
>
> } call_t;
>
> I have a global variable, namely call_pool, which is of type call_t *
>
> My python program:
>
> cp = call_pool # no error doing this, means that call_pool is accessable
Without any glue code? That's weird. What Python implementation is this?
> while cp:
> print cp
> cp = cp.next
>
> This is giving me error: " There is no member or method name c_next"
Doesn't look like a Python exception to me. Cannot find any trace of
that message in the CPython sources either...
> Now, If I just do:
>
> print cp
> print cp.next
>
> there is no problem. But I am seeing a difference in the way python is
> looking at the struct:
>
> print cp -> (call_t*) 0xb0...
> print cp.next -> (struct call *) 0xb0...
>
> Is python not intelligent enough to diagnose the next pointer ??
I've written more C extensions for Python than most people, but I'm
definitely not intelligent enough to decipher your post. What on earth
are you talking about ? Are you sure you're posting to the right
newsgroup ?
</F>
More information about the Python-list
mailing list