sizeof extern arrays

Roger J. Noe rjnoe at riccb.UUCP
Sat Mar 22 09:08:20 AEST 1986


I'm not sure if this is a cc bug or not.  Suppose in a file I have the
definition of a global array, e.g.
		int	foo[43];
Suppose in another file I have a declaration of foo without the dimension and
then refer to the size of the array:
		extern int foo[];
		/* . . . */ sizeof foo / sizeof (int) /* . . . */
Then cc apparently "returns" zero for sizeof foo.  Should this happen
for an extern array?  I know that if I stick in a dimension in the
array declaration in the latter file:
		extern int foo[22];
then the compiler uses that value as the number of elements in the array
rather than the number it was defined as having.  We're running UNIX
System V Release 2 on a VAX-11/785.
--
Roger Noe			ihnp4!riccb!rjnoe



More information about the Comp.lang.c mailing list