Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!ucsd!chem.ucsd.edu!tps From: tps@chem.ucsd.edu (Tom Stockfisch) Newsgroups: comp.lang.c Subject: Re: style Message-ID: <195@chem.ucsd.EDU> Date: 29 Apr 88 05:55:16 GMT References: <13154@brl-adm.ARPA> Reply-To: tps@chem.ucsd.edu (Tom Stockfisch) Organization: Chemistry Dept, UC San Diego Lines: 45 In article <13154@brl-adm.ARPA> dsill@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@chem.ucsd.edu