Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site ssc-vax.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!talcott!panda!genrad!decvax!tektronix!uw-beaver!fluke!ssc-vax!savage From: savage@ssc-vax.UUCP (Lowell Savage) Newsgroups: net.lang.c Subject: Re: more about programming style Message-ID: <86@ssc-vax.UUCP> Date: Mon, 5-Aug-85 13:48:26 EDT Article-I.D.: ssc-vax.86 Posted: Mon Aug 5 13:48:26 1985 Date-Received: Sat, 10-Aug-85 04:42:34 EDT References: <11457@brl-tgr.ARPA> <68@ucbcad.UUCP> <1693@reed.UUCP> <441@myriasb.UUCP> <218@pedsgd.UUCP> Organization: Boeing Aerospace Co., Seattle, WA Lines: 54 *** REPLACE THIS LINE WITH YOUR MICRO, PLEASE *** From Bob Weiler there was this hint: > I find a partial solution to the def problem is to use the following > style of declarations religously. > > #define MYSTRUCT_T struct mystruct > struct mystruct { > int whatever; > MYSTRUCT_T *next; > }; > typedef MYSTRUCT_T mystruct_t, *mystruct_p; > #define MYSTRUCTSZ (sizeof(mystruct_t)) > #define NULLMYSTRUCT ((mystruct_p)0) > > I would appreciate comments, suggestions, etc. on additional ways to > make type declarations more readable. But enough already about ++. Hear! Hear! Another suggestion that I will add is to use typedefs. In this case: typedef struct mystruct { int whatever; mystruct *next; }; mystruct *mystruct_p; #define MYSTRUCTSZ (sizeof(mystruct)) I have always HAD to do this when I was declaring arrays of pointers to functions, as in: typedef struct mystruct { int x; mystruct *nextrv; }; typedef mystruct *ret_val; typedef ret_val func_type(); func_type *func_pt; func_pt func_array[10]; /* An array of pointers to functions returning a pointer to a structure mystruct. */ Perhaps some of the steps could be run together in the same declaration, but it certainly helps when a nested declaration turns into a nested mess of *'s, ()'s, []'s, etc. There's more than one way to be savage, Lowell Savage P.S. I have not checked my declarations very carefully, so they could be wrong, I just tried to bang this out to get the idea across.