Python Extension winth C++ Problematic :(

Chandrashekhar kaushik shekhar.kaushik at gmail.com
Thu Aug 3 17:23:45 EDT 2006


Hi
I have been working getting my C++ code to be used in Python ( Basically
Extending )
This is the problem i am facing rite now.

I have a function that returns a Pointer to a class in my C++ Code

It looks like this

SLSocket* SLSocket::accept( SLHostInfo& client ){
    socklen_t    addrlen = sizeof( struct sockaddr_in );
    int new_fd = ::accept( sock_fd , ( struct sockaddr* )client.address() ,
&addrlen );
    if( new_fd == -1 ){
        sl_set_error(string("SLSocket::accept() : ") + string( sys_errlist[
errno ] ));
        return NULL;
     }else{
        return new SLSocket( new_fd );
     }
}

I have used SWIG to get the Glue code.

When i call this function ( in python ) and it eventually returns ( when it
gets a connection in this case )
it crashes ! I get a SEG FAULT !

Is it some thing that cannot be done ?
Are C++ functions those return pointers a pain in Python

Help :D


--
shekhar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060804/94f48b1d/attachment.html>


More information about the Python-list mailing list