[Gambas-devel] Proper way to the current object

Randall Morgan rmorgan62 at ...176...
Thu Feb 9 15:56:48 CET 2012


Hi Benoit,

I am a bit perplexed. I have some code that works and some that doesn't...
I think I have been looking at the code too long to see the issue. So I was
hoping your eyes might help.

I have used:

#define THIS ((GSLCOMPLEX *) _object)  -- in c_complex.h

to get a pointer to the current object of type GSLCOMPLEX.

Next I use:

THIS->number.real;

to access the value stored in the real member of the number structure. The
number structure is a member of the GSLCOMPLEX structure

The structures are defined as below:

typedef
    struct __GSLCOMPLEXNUM
    {
        double real;
        double imagined;
    }
    GSLCOMPLEXNUM;

typedef
    struct __GSLCOMPLEX
    {
        GB_BASE ob;
        GSLCOMPLEXNUM number;
    }
    GSLCOMPLEX;

This seems to work when I am simply passing a value to store in the
property but causes seg faults when I try to pass the value of
THIS->number.real to a function.
I know I have missed something very elementary but simply can't see it at
this moment... Once you respond I know I will be kicking myself for not
seeing it!

What I need to do is pass the values stored in GSLCOMPLEX->number.real, and
GSLCOMPLEX->number.imagined to c function.

My guess is that my method of getting the current object is not working as
at times I seem to get a null value for THIS and a value of 0x8 for
THIS->number.


Thanks for the help!


-- 
If you ask me if it can be done. The answer is YES, it can always be done.
The correct questions however are... What will it cost, and how long will
it take?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20120209/00a7124d/attachment.html>


More information about the Devel mailing list