Hi,

just a general comment on your questions. Your description below provides
some context (which is fine), but please copy error messages exactly. Just
quoting part of them (especially if you do not understand them), or saying
"does not compile" without further background is not helpful to those who
want to help.

This might help, BTW:

http://www.catb.org/~esr/faqs/smart-questions.html


Mohamed Lrhazi wrote:
> I have two lib functions declared like this:
> 
> void arg_set(handle p, void *arg)
> void arg_get(handle p, void **arg)
> 
> I call arg_set() from an instance of extension type, like this:
> arg_set(handle, <void *>self)
> 
> Hoping to access the instance back in arg_get. So in a callback function I do:
> 
> cdef void** arg
> arg_get(handle, arg)
> 
> But I cannot figure out how to use the retrieved arg, I keep getting
> segfaults, or object has no such attrib type of errors...
> 
> print "call back: config_update: tm_arg_get: 
> ",(<object>(<void*>arg[0])).channel
> 
> What would be the right way to dereference such a pointer?
> 
> I also tried:
> cdef void* arg
> arg_get(handle, &arg)
> print "call back: config_update: arg_get: ",(<object>arg[0]).channel
> 
> But would not compile. gcc dies.

There are several issues here. One is that "arg" is a void* in the last
example, not a void**, so saying (<object>arg[0]) will not work, as an
"object" is a kind of pointer, too. Use "<object>arg". If you want to
figure out what's happening, add a "print <int>arg" to see the value of the
pointer, and compare it to what you put in.

Then, the segfaults you get are likely due to the object being no longer
there (or maybe some other reason, can't tell from what you write). Please
provide some background on how and when the callback is called.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to