Typedef

COTTRELL at BRL.ARPA COTTRELL at BRL.ARPA
Fri Aug 9 05:46:50 AEST 1985


> Typedef is my bugaboo too. When whoever invented it invented it he broke what
> was uptil then a cardinal rule of C........ you could look at a indentifier
> and what was immediately around it and tell exactly what it was
> variable
> array[]
> function()
> "null terminated string"
> 'character'
> along with the non-enforced rule that defined constants were in capitals.
> CONSTANT
> maybe what is needed is some such rule (as for defined constants) that lets
> you know immediately that you are looking at a type name rather than a variable.
> Also at Intel we used to use first letter capitalized to indicate a macro
> function.

I beg to differ. I typedef all my struxures. Makes casts shorter.
	typedef struct foo {
		...
		...
	} FOO, *FOOP;
	FOO	foo = { ...,...};
	FOOP	foop = foo;
	FOOP	barp;
	...
	...
	barp = (FOOP) <expression>;	/* loox better than */
	barp = (struct foo *) <exp>;	/* noisy */

Besides, you've got problems with #defines anyway.

	#define	variable	function()
	#define field		ptr->fld

I suppose you disdain these as well. When used carefully & consistantly,
these can be a boon to readability.

	jim		cottrell at nbs
*/
------



More information about the Comp.lang.c mailing list