don't get a correct memory address at a getter Method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

don't get a correct memory address at a getter Method

Doralicio
Hi,

being new to the FFI, I hope this might have an easy solution:

The following (GHC 6.12.1),

---------------------- C++ lib
class A {
public:
     B* getB(){ B* ptr= &b; cerr << "C: " << << endl; return ptr; }
private:
     B b;
}
---------------------- C wrapper
B* A_getB(A* a){ a->getB(); }
---------------------- Haskell lib
foreign import ccall unsafe "A_getB"
   a_getB:: APtr-> IO BPtr
...
   getB = a_getB
---------------------- Haskell app
   b <-getB a
   putStrLn ("HS: "++show b)
----------------------

leads to deviated pointer addresses, e.g.,
     ...
     C: 0x19bc808
     HS: 0x00007fa92f812c80
     ...

Do you know a solution? Am I doing something wrong?

Thanks in advance,

     Nick


_______________________________________________
FFI mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ffi
Reply | Threaded
Open this post in threaded view
|

Re: don't get a correct memory address at a getter Method

Lemmih
On Fri, Aug 27, 2010 at 11:12 PM, Nick Rudnick
<[hidden email]> wrote:

> Hi,
>
> being new to the FFI, I hope this might have an easy solution:
>
> The following (GHC 6.12.1),
>
> ---------------------- C++ lib
> class A {
> public:
>    B* getB(){ B* ptr= &b; cerr << "C: " << << endl; return ptr; }
> private:
>    B b;
> }
> ---------------------- C wrapper
> B* A_getB(A* a){ a->getB(); }

B* A_getB(A* a){ return a->getB(); } ?

--
Cheers,
  Lemmih
_______________________________________________
FFI mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ffi