Help me cast this!: Ultrix 2.x bug

William E. Davidsen Jr davidsen at steinmetz.ge.com
Thu May 12 02:27:25 AEST 1988


There is an argument for allowing &a. If you have a typedef and don't
need the user to be aware of the inner workings, you would have to know
if the typedef evaluated to an array, to prevent warnings.

Consider:
  typedef int ary[10];		/* system dependent header	*/

  ary mystuff;			/* user declaration		*/
  do_init(&mystuff);		/* warning here			*/

If the user just uses 'mystuff' without the '&' the program must be
rewritten if the internal structure of type 'ary' changes. The solution
is to force a structure, thus:
  typedef struct { int vect[10]; } ary;

Then either the item or the address can be used, and only the procedures
which work with the contents of the structure need to know its contents.

-- 
	bill davidsen		(wedu at ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.lang.c mailing list