[comp.lang.c] Distributed Declarations

pardo@june.cs.washington.edu (David Keppel) (06/21/88)

I have written a series of routines to implement circular
doubly-linked lists.  I want to be able to use these routines to
manipulate several kinds of data structures in one program.  I am
having troubles figuring out how to make the appropriate declarations.

The basic structure that the list routines manipulate looks like:

	struct q_t {
	    struct q_t *forward_link, *backwards_link;
	    int  tag;
	}

What I want to be able to do is to declare various objects that
have varioius sizes of "other" data in them, so I can say

	foo_header_t hdr;
	thing = (cast*)malloc( sizeof(foo_t) );
	other_thing = (cast*)malloc( sizeof(bar_t) );

	enqueue( &hdr, thing, FRONTEND );
	enqueue( &hdr, other_thing, FRONTEND );

where "foo_header_t", "thing", and "other_thing" share the common q_t
as the first N bytes but have different things as the rest of the
elements.  My problem is that I haven't figured out how to declare
this except as a union type;  I don't want to do this because a
"thing", in my case, has only a few bytes of data, while an
"other_thing" has a huge ammount of data.

Can somebody please tell me how to do this correctly?  Advance Thanks.

E-mail appreciated.  I will summerize if anybody is interested.

	;-D on  ( I'm lost in a sea of opportunities )  Pardo

		    pardo@june.cs.washington.edu
    {rutgers,cornell,ucsd,ubc-cs,textronix}!uw-beaver!uw-june!pardo