[Gambas-devel] Proper way to the current object

Benoît Minisini gambas at ...1...
Sat Feb 11 20:20:22 CET 2012


Le 09/02/2012 15:56, Randall Morgan a écrit :
> 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!
>
>

Please be more precise. Which code does not work exactly?

-- 
Benoît Minisini




More information about the Devel mailing list