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