[PD-dev] problem compiling external

IOhannes m zmoelnig zmoelnig at iem.at
Mon May 8 19:07:49 CEST 2006


michael gross wrote:
> hello
> 
> 
> btw i have another newbe question. if i need global variables for the pd
> external where would i put them and what would be the simplest case where

well, you in the sample code you provided, you already have global 
variables. (you might want to declare them static too).
to make local variables put them into the "obj1" struct.


> you acctually have to write a deconstructor. in the tutorial externals
> there was nowhere a deconstructor specified.
> 

oh, i forgot that...

<code>
obj1_class = class_new(gensym("obj1"), (t_newmethod)obj1_new, 0,
</code>

the "0" argument after the constructor is really a pointer to the 
destructor.
so you have to write your destructor function:

void obj1_free(t_obj1*x){
  /* Doh.... */
}

and then do
obj1_class = class_new(gensym("obj1"), (t_newmethod)obj1_new, 
(t_method)obj1_free, ...


and you really should declare all functions (but the setup()!) as 
"static" unless you have reasons to not do so...

mfga.sd.r
IOhannes




More information about the Pd-dev mailing list