Thanks to Han's help page (<a href="http://puredata.info/docs/developer/mingw" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://puredata.info/docs/developer/mingw</a>) I was able to compile a test external on windows with mingw.
<br><br>I then started making a new external called getdollarzero based on getdir (from ggee) and parentdollarzero (from iemlib2). I compiled it and it works but I had to:
<br>1) remove Guenter's hack from getdir's source code<br>2) and therefore include g_canvas.h<br><br>My question is the following: why is there a hack in the first place? If I do not use it will my code crash PD in some way (I compiled against PD
0.4 and worked fine during testing)?<br><br>As a reference, here is my code with the hack commented out :<br><br><br>--------- getdollarzero --------<br clear="all"><br>#include "m_pd.h"<br>#include "g_canvas.h" //needed to include g_canvas.h once the hack was commented out
<br><br><br>/* HACK<br>struct _glist<br>{<br> t_object gl_obj; // header in case we're a glist<br> t_gobj *gl_list; // the actual data<br> struct _gstub *gl_stub; // safe pointer handler
<br> int gl_valid; // incremented when pointers might be stale<br> struct _glist *gl_owner; // parent glist, supercanvas, or 0 if none<br>};<br><br>END HACK<br>*/<br><br>typedef struct getdollarzero
<br>{<br> t_object x_ob;<br> t_canvas * x_canvas;<br> t_outlet* x_outlet;<br> int x_level;<br>} t_getdollarzero;<br><br><br><br><br>static void getdollarzero_bang(t_getdollarzero *x)<br>{<br> int i = x->x_level;
<br> t_canvas* last = x->x_canvas;<br><br> while (i>0) {<br> i--;<br> if (last->gl_owner) last = last->gl_owner;<br> }<br> // code example taken from iemlib2's parentdollarzero:<br>
// x->s_parent_unique = canvas_realizedollar((t_canvas *)this_canvas->gl_owner, gensym("$0")); <br> // original get dir function:<br> //outlet_symbol(x->x_outlet,canvas_getdir(last));<br><br> outlet_symbol(x->x_outlet,canvas_realizedollar(last, gensym("$0")));
<br>}<br><br>t_class *getdollarzero_class;<br><br>static void *getdollarzero_new(t_floatarg level)<br>{<br> t_getdollarzero *x = (t_getdollarzero *)pd_new(getdollarzero_class);<br> x->x_canvas = canvas_getcurrent();
<br> x->x_outlet = outlet_new(&x->x_ob, &s_);<br> x->x_level = level;<br> return (void *)x;<br>}<br><br>void getdollarzero_setup(void)<br>{<br> getdollarzero_class = class_new(gensym("getdollarzero"), (t_newmethod)getdollarzero_new, 0,
<br> sizeof(t_getdollarzero), 0, A_DEFFLOAT,0);<br> class_addbang(getdollarzero_class, getdollarzero_bang);<br>}<br><br>--------- getdollarzero end --------<br clear="all"><br>-- <br>thomas ouellet fredericks,
<a href="mailto:tof@danslchamp.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tof@danslchamp.org</a>, montreal, canada