Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!talcott!panda!genrad!decvax!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: net.lang.c Subject: Re: Array of pointers to functions Message-ID: <295@dg_rtp.UUCP> Date: Fri, 11-Apr-86 15:32:40 EST Article-I.D.: dg_rtp.295 Posted: Fri Apr 11 15:32:40 1986 Date-Received: Mon, 14-Apr-86 02:38:42 EST References: <2456@brl-smoke.ARPA> Lines: 39 Summary: nag, nag, nag AAAAUUUUGGGGHHHH!!!! > Yesterday I asked which was right: > "int (*foo[SIZE])()" or "int ((*foo)())[];" > The solution I got was to look at declarations from the inside out; thus > int foo - An integer > int *foo - A pointer to an integer > int (*foo)[] - An array of pointers to integers > int ((*foo)[])() - An array of pointers to functions > returning integers. Puh*LEEZE* try to be a little more careful, folks. It is probable that the error in the above is a typo, but typo or not, it spreads misinformation. The general principle of declaring from the inside out is correct as stated above, but the last two examples are *INCORRECT*. In particular, (*foo)[] is a pointer to an array, not an array of pointers. Read it from the inside out folks... pointer operation first, then array, hence "pointer to array". Similarly for the last example. It is a pointer to an array of functions returning int, which isn't even legal in C. If the last example had been typechecked before posting, it would have been obvious that it was bogus... lint barfs all over it, saying: array of functions is illegal In addition, a local typechecker gives a somewhat more verbose admonition, like so: arrays cannot contain this type (:FUNCTION_RETURNING (:INT)) As I've said before, puh*LEEZE* be more careful, and (where possible) *TYPECHECK* *POSTED* *EXAMPLES* (with lint at least, and maybe more if you've got more). -- Wayne Throop at Data General, RTP, NC !mcnc!rti-sel!dg_rtp!throopw