Hi,
I'm having problems trying to define an array of type t_outlet. here's the code:
#include "m_pd.h"
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];//problem code double *x, *y, *z; t_atom *x_out, *y_out, *z_out; } t_shapetape;
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...
thanks,
Brian
p.s. The external I'm developing is for reading data from a serial device called the Shapetape (http://www.measurand.com/products/shapetape.html), which I'll be using as the dynamic system to scan in a scanned synthesis (http://www.csounds.com/scanned/) instrument. If anyone has any advice on developing this sort of external, it would be much appreciated... this is my first ever pd (or max!) object. Also, if anyone out there is interested in scanned synthesis, mail me and I can give more details about my planned digital instrument.
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
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
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@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
On Thu, 17 Jul 2003, Brian Sheehan wrote:
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?
There may be several reasons. That may be one of those. If there were outlet_init() that would not allocate but just initialize, then there would be a need for an outlet_finalize() that deinitializes but without deallocating, and maybe the memory allocation would become the caller's responsibility, or else there would have to be a flag in t_outlet to determine which way the object should be gotten rid of, finalization or also deallocation. That would be somewhat more difficult for almost no reward. That is, unless completely automated deallocation (refcount or marksweep) is implemented in PD, but I don't think that will ever happen.
Else it allows the size of t_outlet to change in PD without recompiling all externals.
________________________________________________________________ Mathieu Bouchard http://artengine.ca/matju