So I have code here for a rather simple pd extern "myclass". It appears to me that what a myclass object should do upon receiving a bang message is post 0 (num gets set to 0 in the constructor, then it justs posts num). However it always posts 1. Does anyone see what could be going wrong here? Thank you very much in advance.
Code:
#include "m_pd.h"
static t_class *myclass;
typedef struct _myclass {
t_object x_obj;
t_int num;
} t_myclass;
void myclass_bang(t_myclass *x)
{
post("%d", x->num);
}
void *myclass_new(void)
{
t_myclass *x = (t_myclass *)pd_new(myclass);
x->num = 0;
return (void *)x;
}
void myclass_setup(void) {
myclass = class_new(gensym("myclass"),
(t_newmethod)myclass_new,
0, sizeof(t_myclass),
CLASS_DEFAULT, 0);
class_addbang(myclass, myclass_bang);
}