Nobuyoshi Nakada
8/18/2008 6:26:00 PM
Hi,
At Mon, 18 Aug 2008 22:31:41 +0900,
Alex Fenton wrote in [ruby-talk:311670]:
> I want to create a ruby method in a C++ extension that will spit out the
> C++ pointer address of the wrapped object - useful for debugging. I
> have got the following, which works, but I was wondering if there was an
> easier way to access this that I'm missing?
rb_sprintf is a function added in 1.9, and you can use it like
printf.
> static VALUE
> cpp_ptr_addr(VALUE self, VALUE obj)
> {
void *ptr = DATA_PTR(obj);
return rb_sprintf("%p", ptr);
> }
--
Nobu Nakada