[PD-dev] FIXED problem defining t_outlet array

Brian Sheehan rbsheehan at yahoo.com
Thu Jul 17 14:24:45 CEST 2003


Thanks Mathieu, that worked. Is it so that we never
have to worry about deallocating memory that
outlet_new is the only way of creating t_outlet
structs?

For the record, this what my code now looks like:

typedef struct _shapetape
{
    t_object x_obj;
    t_clock *x_clock;
    double x_deltime;
    int x_hit;
    t_int points;
    t_outlet *outlets[NUM_OUTLETS];
    double *x, *y, *z, *q1, *q2, *q3, *q4;
    t_atom *x_out, *y_out, *z_out, *q1_out, *q2_out,
*q3_out, *q4_out; 
} t_shapetape;

To create the outlets:

for (i = 0; i < NUM_OUTLETS; i++)
{
    x->outlets[i] = outlet_new(&x->x_obj,&s_list);
}

To write to outlets:

for (i = NUM_OUTLETS - 1; i >=0; i--)
{
    outlet_list(x->outlets[i],
                &s_list,
                size,
                vector[i]);
}
--- Mathieu Bouchard <matju at sympatico.ca> wrote:
> 
> On Wed, 16 Jul 2003, Brian Sheehan wrote:
> 
> > I'm having problems trying to define an array of
> type t_outlet. here's
> > the code:
> > The compiler (gcc3 w/ Project Builder) gives this
> > error:
> > shapetape.c:17: field `outlets' has incomplete
> type
> > I noticed in m_pd.h that t_outlet is #define'd to
> > EXTERN_STRUCT _outlet;
> > Does this mean to include some other header for
> the
> > definition of _outlet? The only place I could find
> a
> > definition was m_obj.c...
> 
> No, outlet structs are only to be produced by the
> outlet constructor,
> called outlet_new(). It must be called with a
> t_object argument, and a
> type specifier symbol.
> 
> You must use pointers to refer to outlets.
> 
> In my code I have something like this that does
> automatic generation of
> a variable number of outlets for all of my objects:
> 
> 	self->bself->out = new t_outlet*[noutlets];
> 	for (int i=0; i<noutlets; i++) {
> 		self->bself->out[i] =
> outlet_new(self->bself,&s_anything);
> 	}
> 
> self->bself is a BFObject, subclass of t_outlet.
> self->bself->out is a t_outlet **.
> 
>
________________________________________________________________
> Mathieu Bouchard                      
> http://artengine.ca/matju
> 

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com




More information about the Pd-dev mailing list