Help on Swig

Gurpreet Sachdeva redhackgp at rediffmail.com
Fri Aug 5 09:57:18 EDT 2005


Hi,
I am facing a problem with swig while using Pointers:

<Array.c>
#include<stdio.h>
void Array(int *ptr)
{
        int i;
        for (i = 0; i < 6; i++)
        {
                printf("Index: %d - %d\n",i, *(ptr + i));
        }
}
<Array.i>
%module Array
%{
extern void Array(int *ptr);
#include<stdio.h>
%}
extern void Array(int *ptr);

While running:

>>> import Array
>>> a=[1,3,2,4,5,6,7,9]
>>> Array.Array(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: argument number 1: a 'int *' is expected, 'list([1, 3, 2, 4, 5, 6, 7, 9])' is received

Do I need to make some changes in Interface file?
Also I need to return that array after sorting it. How do I return it and collect the same in python.

Thanks and Regards,



Cheers!


«·´`·.(*·.¸(`·.¸ ¸.·´)¸.·*).·´`·» 

      «.....[ Garry ].....» 

«·´`·.(¸.·*(¸.·´ `·.¸)*·.¸).·´`·» 

Blogging at http://garrythegambler.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050805/3eeaf44f/attachment.html>


More information about the Python-list mailing list