[PD-dev] object creation bug?

Yves Degoyon ydegoyon at free.fr
Sat Aug 3 16:42:48 CEST 2002


hi, thomas,

reworked a little bit your code
to put it in a good ol' C style.

this one works : the main modification
is the inversion of ( float, symbol ) ---> ( symbol, float ),
when i change it back, it crashes....

so, i guess you pinpointed a real bug.

-----------------------------------------------------------------------------------------------------------
#include "m_pd.h"

struct simple_t { t_object obj; };
static t_class *simple1_class;

t_class* class_simple1 ( t_symbol *arg1, float arg2)
{
    post("argument 1: %s ",arg1->s_name);
    post("argument 2: %f ",arg2);
    return NULL;
}

void simple1_setup(void)
{
 simple1_class = class_new( gensym("simple1"), (t_newmethod)class_simple1,
                            NULL, sizeof(struct simple_t), CLASS_DEFAULT,
                            A_SYMBOL, A_FLOAT, A_NULL);
}
-----------------------------------------------------------------------------------------------------------

hope this helps,

cheers,

sevy/yves

Thomas Grill wrote:

>Hi Miller, hi all,
>i'm stuck with the following codelet:
>
>--
>snip -----------------------------------------------------------------------
>-----
>
>#include "m_pd.h"
>
>struct simple_t { t_object obj;  };
>static struct _class * simple1_class;
>
>_class* class_simple1 (float arg1, t_symbol *arg2)
>{
>/* arg1 and arg2 are invalid!! */
> post("arguments: %f %s",arg1,arg2->s_name); /* seg fault!! */
>    return 0;
>}
>
>extern "C" __declspec(dllexport) void simple1_setup()
>{
> simple1_class = class_new( gensym("simple1"),
>(t_newmethod)class_simple1,NULL,sizeof(simple_t), 0, A_FLOAT, A_SYMBOL,
>A_NULL);
>}
>
>--
>snip -----------------------------------------------------------------------
>-----
>
>It's simple as can be. I defined a object having a float and a symbol a
>creation arguments.
>The new method "class_simple1" gets invalid values for arg1 and arg2,
>though.
>It's the same for 0.34-4 and 0.35
>If it's a PD bug then it's strange that noone noticed it before.....
>
>greetings,
>Thomas
>
>
>
>_______________________________________________
>PD-dev mailing list
>PD-dev at iem.kug.ac.at
>http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-dev
>
>






More information about the Pd-dev mailing list