Using C struct in Python** corrected

Sudheer Gupta sudheerb at netapp.com
Wed Jun 7 17:38:29 EDT 2006


Hi,

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

while cp:
      print cp
      cp = cp.next


This is giving me error: " There is no member or method name c_next"

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 ??

Responses appreciated.

Thanks
Sudheer



More information about the Python-list mailing list