5[array] (was Re: "for" loops in C ...)

Chris Torek chris at mimsy.UUCP
Thu Nov 10 09:43:21 AEST 1988


In article <351 at chem.ucsd.EDU> tps at chem.ucsd.edu (Tom Stockfisch) writes:
[compressed vertically]
>So how come
>	int	5[a], 5[*b];
>isn't a legal declaration equivalent to
>	int	a[5], (*b)[5];
>and the following isn't a legal cast?
>	(int 10[*])

Because the `declaration mirrors use' rule is only an approximation.
(Tom was no doubt asking rhetorically, but no doubt someone will
misunderstand.) Mainly, it breaks down with array declarations and
use.  This is probably the cause of most of the confusion as to why
code like

	/* file1.c */
	char text[] = "foo the bar";

	/* file2.c */
	extern char *text;
	/* ... code referencing *(text+n) ... */

fails.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list