Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Variable Name Conventions Message-ID: <1990Jan19.183036.24440@utzoo.uucp> Organization: U of Toronto Zoology References: <36190@cornell.UUCP> Date: Fri, 19 Jan 90 18:30:36 GMT In article <36190@cornell.UUCP> gordon@cs.cornell.edu (Jeffrey Adam Gordon) writes: >I have seen C source with at least three different types of variable >names. Some are just 'var' while others are either '_var' or '__var.' >What I'd like to know is: is there any convention for using >underline (and for that matter, CAPS) in C variable/function/structure >names... Ignoring some fine points, names with leading underscores are basically reserved for use by the implementation. You use such names for your own purposes at your peril. The implementation may make some such names available to you for specific purposes: for example, __STDC__ as a preprocessor macro to test whether you've got an ANSI-standard compiler. There are various naming schemes for identifiers. Probably the most widely used is a vague standard common in Unix sources and among long-time C programmers: type names end in _t, macro names are all caps, ordinary variable names are all lowercase, and there are no particular stylistic conventions depending on variable type. There is also the convention of starting structure member names with xx_, where xx is an abbreviated version of the structure name, but that's largely an artifact of now-obsolete namespace structure in early compilers. -- 1972: Saturn V #15 flight-ready| Henry Spencer at U of Toronto Zoology 1990: birds nesting in engines | uunet!attcan!utzoo!henry henry@zoo.toronto.edu