[C++-sig] How to hangle a NULL pointer?

Luiz Vitor Martinez Cardoso grabber at gmail.com
Tue Oct 2 18:29:55 CEST 2012


Dear,

I've a simple C++ class containing the following members:

    quint32 mergeCount;
    quint64 timestamp;
    quint32 id;
    quint32 score;
    quint32 lastScore;
    quint32 uptime;
    qint32 * gender;
    float * age;
    float * ageDeviationDen;
    quint32 * happy;
    quint32 * sad;
    quint32 * surprised;
    quint32 * angry;

All the members are initialized to 0 or NULL if it's a pointer.

The problem is that I'm getting a "Segmentation Fault" message when I try
to access the pointers members from Python.

The code I'm using to map the attributes are:

void export_FaceObject()
> {
>     class_<FaceObject, boost::noncopyable>("FaceObject", init<>())
>        .add_property("mergecount", &FaceObject::getMergeCount)
>        .add_property("id", &FaceObject::getId)
>        .add_property("timestamp", &FaceObject::getTimestamp)
>        .add_property("score", &FaceObject::getScore)
>        .add_property("lastscore", &FaceObject::getLastScore)
>        .add_property("uptime", &FaceObject::getUptime)
>        .add_property("gender", &FaceObject::getGender)
>        .add_property("age", &FaceObject::getAge)
>        .add_property("agedeviation", &FaceObject::getAgeDeviation)
>        .add_property("happy", &FaceObject::getHappy)
>        .add_property("sad", &FaceObject::getSad)
>        .add_property("surprised", &FaceObject::getSurprised)
>        .add_property("angry", &FaceObject::getAngry)
>     ;
> }


What can I do? I know that I need to use a CallPolicy but I already have
tried several combinations without any success.

Best regards,
Luiz Vitor.

-- 
Regards,

Luiz Vitor Martinez Cardoso
Celular: (11) 7351-7097 | Skype: grabberbr
engineer student at maua.br
<http://maua.br>intern marketing engineer at geindustrial.com.br
entrepreneur at adboxnetwork.com

"If you wanna be successful, you need total dedication, go for your last
limit, give your best and love your love infinitely!"

"The only limits are the ones you place upon yourself"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121002/a9889364/attachment.html>


More information about the Cplusplus-sig mailing list