structure references in header files

Geoff Kuenning geoff at desint.UUCP
Sat Dec 14 16:36:09 AEST 1985

People who want to write maximally portable should also note the following
technique, so that they can avoid it:

    typedef struct foo *ZAP;
    typedef struct bar *ZOW;

    struct foo
	ZOW *zowie;

    struct bar
	ZAP zapped;

Since pcc (and, I believe, the original pdp-11 compiler) treats typedefs
as macros, this works on those compilers.  However, it breaks lint, and
it breaks on many compilers that actually treat typedefs as types, since
the structs are undefined at the time of the typedef statement.

	Geoff Kuenning

More information about the Comp.lang.c mailing list