Using data types before they are declared.

Vorl. Informationssysteme db2 at pbinfo.UUCP
Wed Jun 14 18:55:18 AEST 1989


In article <10268 at watcgl.waterloo.edu> awehrmann at watcgl.waterloo.edu (August Wehrmann) writes:
>I have a question: 
>
>Is it possible, (and if so, how?), to use a data type in a declaration
>of say, a union, that has not yet been declared?
>
>[Example omitted]
>
>union Fred {              <--------
>	int 	Number;            |
>	element	Node;     <...........
>};                                 | .
>                                   | .
>typedef struct {                   | .
>	int	Info;              | .
>	Fred	Name;     <--------  .
>} *element;               <...........
>
>Thanks in advance.
>

I would use the following:

union Fred {
	int		Number;
	struct _el_str	*Node;
};

struct _el_str {
	int	Info;
	Fred	Name;
};
typedef	struct _el_str	*element;

I am practising this in my own programs very often.

	D. Aedal
	YACSS (Yet Another CS Student)



More information about the Comp.lang.c mailing list