<div dir="ltr">thanks IOhannes, that's very helpful. by changing the callback signature to:<div><br></div><div>euclid_new(t_symbol *s, int argc, t_atom *argv)</div><div><br></div><div>i was able to get it working with A_GIMME. but one thing still bothers me: this is the constructor for the class, and i really only want to support instantiation with a single (float) creation argument. why should i have to jump through the hoops of A_GIMME? shouldn't the following signature:</div><div><br></div><div>euclid_new(t_floatarg f)<br></div><div><br></div><div>registered with class_new(..., A_DEFFLOAT) be sufficient for this simple case? this worked for me on 0.43.4; why doesn't it work in 0.47?</div><div><br></div><div>thanks again,</div><div><br></div><div>_chris</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 6, 2017 at 3:57 AM, IOhannes m zmoelnig <span dir="ltr"><<a href="mailto:zmoelnig@iem.at" target="_blank">zmoelnig@iem.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2017-02-06 07:42, Chris Chronopoulos wrote:<br>
> Code is attached. Any suggestions? What's this typechecking/A_GIMME<br>
<br>
</span>Pd has special, "optimized" functions to check the types of arguments.<br>
<br>
basically, if you have a callback function (and from a pure "C"<br>
perspective, the class-methods of an objects are callback functions),<br>
you must correctly call that function.<br>
that is: if the callback function expects a symbols and then a float<br>
("void foo_mess(t_myobject*x, t_symbol*s, t_float f)"), you must<br>
actually call it with a symbol and then a float ("foo_mess(x, s2,<br>
2.3)"), to ensure that the compiler will put the correct bits at the<br>
right positions.<br>
<br>
now in Pd, an external can wish for "any" function signature of the<br>
callback it wishes for, but it is the task of Pd (core) to actually call<br>
that callback function correctly.<br>
since "any" signature is pretty broad and it is tedious to write special<br>
callback callers for all the possibilities, it offers a (slightly less<br>
convenient) generic solution for "non-standard" callbacks: pass a list<br>
of atoms (aka A_GIMME)<br>
messages with more that 5 atoms are "non-standard", and therefore you<br>
must use A_GIMME.<br>
<br>
the function signature of an A_GIMME is:<br>
  int argc, t_atom*argv<br>
you then can iterate over the <argc> atoms in the <argv> array, and use<br>
them whoever you please (mainly: check that each element is of correct<br>
type, and use atom_getfloat() resp atom_getsymbol() to acccess the values).<br>
<br>
i suspect (without having looked at your code), that you were simply<br>
changing the type to A_GIMME when registering the callback (in the<br>
class_addmothod() function), but then didn't bother to change the<br>
function signature of the actual callback function.<br>
<br>
so if your callback signature is:<br>
 void foo_mess(t_myobject*x, t_symbol*s, t_float f);<br>
and you register it with<br>
 class_addmethod(x, (t_method)foo_mess, gensym("foo"), A_GIMME, 0);<br>
<br>
then the system will end up calling foo_mess with the following arguments:<br>
- the first 4 bytes are the address to the object (good)<br>
- the next 4 bytes are an int value (bad because you are expecting the 4<br>
bytes to be the address of a symbol)<br>
- the next 4 bytes being the address of some t_atom-array (bad, because<br>
you are expecting it to be 4 bytes of an ieee758 floating point number)<br>
(for the sake of simplicity the above example assumes a 32bit system)<br>
<br>
if you then happen to dereference so-acquired symbol, it will hopefully<br>
go kaboong (hopefully insofar as it will go kaboong without launching<br>
the missilies first)<br>
<br>
<br>
mfgasdr<br>
<span class="HOEnZb"><font color="#888888">IOhannes<br>
<br>
</font></span><br>______________________________<wbr>_________________<br>
<a href="mailto:Pd-list@lists.iem.at">Pd-list@lists.iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -> <a href="https://lists.puredata.info/listinfo/pd-list" rel="noreferrer" target="_blank">https://lists.puredata.info/<wbr>listinfo/pd-list</a><br>
<br></blockquote></div><br></div>