self contained pointers to structures

Doug Gwyn gwyn at smoke.BRL.MIL
Tue Nov 28 07:47:04 AEST 1989


In article <10350 at attctc.Dallas.TX.US> bobc at attctc.Dallas.TX.US (Bob Calbridge) writes:
>struct event {
>	struct	event *next;
>};
>Of course, the compiler complains because the definition of the structure is
>incomplete at that point.

What do you mean, "of course"?  That is a perfectly valid C construct and
is in fact quite common.

Some deficient compilers do have a problem with such constructs, and there
are a number of work-arounds possible.  One is

struct event;	/* incomplete type to get entry into symbol table */
struct event {
	struct event *next;	/* should be accepted now */
};



More information about the Comp.lang.c mailing list