[PD-dev] getting the classname in an class
Hans-Christoph Steiner
hans at eds.org
Fri Oct 26 21:05:39 CEST 2007
On Oct 26, 2007, at 2:13 PM, Martin Peach wrote:
> Hans-Christoph Steiner wrote:
>> Ok, I've seen a number of different ideas for how to get the
>> complete classname an object was instantiated with from within
>> that class, but I haven't been able to get one working.
>>
>> Krzysztof did this in externals/miXed/cyclone/hammer/universal.c:
>>
>> t_gobj *g;
>> for (g = glist->gl_list; g; g = g->g_next)
>> if (pd_class(&g->g_pd)->c_name == cname) /* LATER rethink */
>> pd_bang(&g->g_pd);
>>
>>
>> I tried this in my code, but got an error:
>>
>> binbuf_addv(b, "ssiisiiss", gensym("#X"),gensym("obj"),
>> x->x_obj.te_xpix, x->x_obj.te_ypix, pd_class(&z-
>> >g_pd)->c_name,
>> x->x_width, x->x_height, x->x_bgcolour, x-
>> >x_fgcolour);
>>
>> entry.c:504: error: dereferencing pointer to incomplete type
>
> I think it's because pd_class just dereferences a pointer and a
> t_class is just a pointer to an unspecified struct. You need to
> specify what kind of class you're pointing at.
>>
>>
>> I think IOhannes recommended this, but I get the same error:
>>
>> binbuf_addv(b, "ssiisiiss", gensym("#X"),gensym("obj"),
>> x->x_obj.te_xpix, x->x_obj.te_ypix, (*(t_pd *)x)-
>> >c_name->s_name,
>> x->x_width, x->x_height, x->x_bgcolour, x-
>> >x_fgcolour);
>>
>> entry.c:504: error: dereferencing pointer to incomplete type
>
> Again, x is just a pointer to a struct but the compiler doesn't
> know which kind of struct.
>
>
>>
>> Any suggestions?
>
> Specify the class type that x points to.
>
> Martin
>
Any specific suggestions? You mean casting as (entry_class) or
something like that?
.hc
------------------------------------------------------------------------
----
You can't steal a gift. Bird gave the world his music, and if you can
hear it, you can have it. - Dizzy Gillespie
More information about the Pd-dev
mailing list