style

Tom Stockfisch tps at chem.ucsd.edu
Fri Apr 29 15:55:16 AEST 1988


In article <13154 at brl-adm.ARPA> dsill at nswc-oas.arpa (Dave Sill) writes:
>Tom Stockfisch [THAT'S ME] writes:
>>In this case you can use
>>
>>	typedef struct LIST {
>>		struct LIST	*link;
>>		data_t		data;
>>	}	LIST;
>>
>>since tags and typedefs are in different overload classes.
>>This usage is not strange looking if you think of the
>>initial "struct LIST" as meaning "BEGIN LIST DECLARATION"
>>and the final "LIST;" as "END LIST DECLARATION".
>
>Yuck.  Although legal, taking advantage of separate name spaces
>like this is material for Obfucated C Code Contest entries.

Everyone's entitled to their opinion.  This is, however, essentially
what happens in C++, where you get an automatic typedef of the same
name for every struct tag.  Are you saying that you would want to save
the tag for a different use, as in

	typedef int	LIST;
	struct LIST	{ ... };	?

If not, why object?

>This example also comflicts with the popular convention of using
>uppercase-only names for macros.

For better or for worse, there are many different conventions for
upper/lower case and capitalized/uncapitalized.
I quit using lower case names for typedefs after running into the
pcc bug (I've been told it's in all pcc compilers and will never
be fixed) in which local (auto) declarations do not hide outer typedef
names, even tho this is guaranteed in K&R p. 206 (1st ed.):

	typedef float	distance;
	...
	{
		auto int	distance;

The above won't work on my compiler.  Hence, the all-caps for typedefs.
-- 

|| Tom Stockfisch, UCSD Chemistry	tps at chem.ucsd.edu



More information about the Comp.lang.c mailing list