Path: utzoo!mnetor!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: While talking about useful additions, how about this one?? Message-ID: <2528@haddock.ISC.COM> Date: 9 Feb 88 21:50:52 GMT References: <253@vsi1.UUCP> <127@ghostwheel.UUCP> <7169@brl-smoke.ARPA> <131@ghostwheel.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 22 Summary: "struct *" can be done with existing constructs In article <131@ghostwheel.UUCP> ned@ghostwheel.aca.mcc.com.UUCP (Ned Nowotny) writes: >[Re "struct *" for a generic pointer to a structure] >I don't want to mix pointers to different structure types, but I do want >to write generic code which manipulates complex objects (e.g. linked list >managers). How about writing "struct generic *", where "struct generic" is never defined? This is already syntactically and semantically legal. >As a rational, consider that given "int a, b;", "int *a_ptr;" declares a >pointer which may freely point to either "a" or "b" Yes; so "int *" is a pointer to any int. But it can't point to a short int or a long int. The analogy is pretty weak, I'd say. >In fact, given: "typedef int a_int; typedef int b_int;" [both cc and lint >allow mixing of the two types]. That's because typedef creates a new name for an existing type, rather than a new type. You want dimensional analysis? I'm working on it. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint