<div dir="ltr">oh, i see. i thought the argument after A_DEFFLOAT was the default value of the float. so it's a 0-termination - got it!</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 13, 2017 at 4:03 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-12 22:23, Chris Chronopoulos wrote:<br>
> registered with class_new(..., A_DEFFLOAT) be sufficient for this simple<br>
> case? this worked for me on 0.43.4; why doesn't it work in 0.47?<br>
><br>
<br>
</span>oh.<br>
<br>
of course Pd can do *that* for you.<br>
the problem here is, that your code is just bogus:<br>
class_new() expects a variable number of arguments.<br>
but in C there is no way to determine the actual number of arguments<br>
passed to the function.<br>
So you need to somehow tell the called function when it should stop to<br>
expect more arguments.<br>
<br>
this can either be done by putting that number into one of the<br>
function-arguments. an example is the `dsp_add()` function. e.g.:<br>
<br>
    dsp_add(clip_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);<br>
<br>
the second argument (4) tells the dsp_add() function that there are 4<br>
more arguments to come.<br>
<br>
alternatively (if the data permits it), you can use a special<br>
"terminating") element with a magic value (usually this is just NULL);<br>
the function would then read it's arguments one by one until in<br>
encounters that special argument, after which it would stop.<br>
this is the case with the class_new() function. e.g.:<br>
<br>
    clip_class = class_new(gensym("clip~"), (t_newmethod)clip_new, 0,<br>
        sizeof(t_clip), 0, A_DEFFLOAT, A_DEFFLOAT, 0);<br>
<br>
the varidiac part is "A_DEFFLOAT, A_DEFFLOAT" and it *must* be<br>
0-terminated. so class_new() knows that there are only two (2) more<br>
valid arguments.<br>
<br>
it seems that with your call to class_new(), you were just "lucky" and<br>
the compiler you used back then with Pd-extended happened to insert a<br>
NULL value after your A_DEFFLOAT.<br>
so your statement "this worked for me on 0.43" should actually read:<br>
"this accidentally happened to work for *me* at some point".<br>
<br>
but really you were relying on undefined behaviour, and should just fix<br>
the original code.<br>
<br>
fgamsdr<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>