[PD-dev] shared class data and functions

Jonathan Wilkes jancsika at yahoo.com
Wed Nov 14 08:17:30 CET 2012


I have three classes:
foo, bar, bow

Foo has a function:

void foo_blah(t_foo *x, t_symbol *s, t_int argc, t_atom *argv)
{
    if(x->x_member == 1) do_something...
}

Bar and bow both have x->x_member, too, and I want all three
to use the same function so I don't have to copy it two more times.
Is there a way to do this:

void foo_blah(t_pd *x, t_symbol *s, t_int argc, t_atom *argv)
{
    if we can cast x to t_foo, t_bar or t_bow then
    check if x has x->member equal to 1, and if so then do_something...

}

which I can call by sending t_foo, t_bar or t_bow as the first
arg to that function?

It seems like I should be able to do this but I can't figure out all the
pointer bs.

-Jonathan




More information about the Pd-dev mailing list