dg3s+@andrew.cmu.edu (David Gentzel) (09/28/89)
A friend of mine has been put in charge of coming up with a C (and C++) style guide for his company. The goals are 1) Name and comment conventions to enhance comprehension and maintainability on projects with large numbers of programmers. 2) Guidelines for writing portable code. 3) Common coding mistakes to avoid (and the usual symptoms if they are not avoided). 4) Miscellaneous (debugging tips, macro guidelines, typedef's, etc.). What I would like to ask from the net readers are 1) Pointers to publications which address these issues (books, periodicals, ftp'able guides). 2) Pointers to (or collections of) some of the "classic" comp.lang.c articles on common misunderstandings (such as Chris Torek's highly valuable periodic posts on proper definition of NULL and differences between pointers and arrays). Thanks for any help you can give me (and him)! Dave Gentzel Pittsburgh Supercomputing Center gentzel@godot.psc.edu or gentzel@a.psc.edu
cml@tove.umd.edu (Christopher Lott) (09/28/89)
In article <oZ8MU0G00WB70biUAO@andrew.cmu.edu> dg3s+@andrew.cmu.edu (David Gentzel) writes: >A friend of mine has been put in charge of coming up with a C (and C++) style >guide for his company..... I am told that the Indian Hill Style Guide (sp?) from Bell Laboratories is not available at any price, etc. to people outside that organization. I've never seen it, and can't comment. I can reccommend a document by Gary Perlman of The Ohio State University's Computer & Information Science Department, titled "C Coding Style & Lore." I do not think that this paper has been published, and when I last checked, it was only available from the author in hardcopy form. It is a terrific place to start for such a company-wide document. I have it, but it's difficult to email the hardcopy version :-). Contact Dr. Perlman at perlman@cis.ohio-state.edu. [Disclaimer: I graduated from OSU and took several of his classes.] Then there are the "10 Commandments for C Programmers" which I have; my version was produced by Henry Spencer. (also the author? think so.) I have saved all of Chris Torek's tutorials that I have seen, all of which I can pass on. They are extremely helpful on technical issues; maybe not so much for style. And finally I can recommend the GNU C Coding Standard, which I also have. Perhaps it would be better to request an updated version from the Free Software Foundation, but I will certainly pass mine on. I contacted Len Tower (tower@wheaties.ai.mit.edu). Another good reference, more general, is _The_Elements_of_Programming_Style_, by Kernighan and Plaugher. (Don't quote me on the authors.) I hope this helps. chris... cml@tove.umd.edu Computer Science Dept, U. Maryland at College Park 4122 A.V.W. 301-454-8711 <standard disclaimers>
roelof@idca.tds.PHILIPS.nl (R. Vuurboom) (09/29/89)
In article <oZ8MU0G00WB70biUAO@andrew.cmu.edu> dg3s+@andrew.cmu.edu (David Gentzel) writes: >A friend of mine has been put in charge of coming up with a C (and C++) style >guide for his company. The goals are > > 1) Name and comment conventions to enhance comprehension and > maintainability on projects with large numbers of programmers. > 2) Guidelines for writing portable code. > 3) Common coding mistakes to avoid (and the usual symptoms if they > are not avoided). Maybe there's no need to re-invent the wheel on this one. For portabilty issues the best book (by far) I've seen on this subject is: Portability and the C language Rex Jaeschke Hayden Books (1988) ISBN-0-672-48428-5 Jaeschke also discusses the impact of the ANSI-C standard which is particularly interesting for this group and the group next door (comp.std.c). Another interesting book on portability is: Portable C and UNIX System Programming J.E. Lapin Rabbit Software Prentice-Hall (1987) ISBN-0-13-686494-5 This book is aimed specifically at porting code between UNIX and its derivative systems. It describes a port philosophy, briefly covers C language issues, and concentrates on the operating system and library issues. The best I've seen on coding style standards is something Philips has come up with: C Coding Standards (Release 1.1). J.Aerts and J.Langhout (1988) Order nr: 12NC: 4322 270 50001 Its about 70 pages thick. An (arbitrary) sample section: 6.2 The use of ++ and -- These operators are very often used in the manipulation of pointers. Together with the definition of "register pointer" these operators may result in a saving of both execution time and program space. The use of "name_p++;" is preferred to "name_p = name_p + 1;" as the former is more suited for the task of setting a pointer to the next element in of an array. Do not use "++" and "--" in actual function or macro parameters, e.g: call_fn(x++,y++,*x,*y); /* WRONG */ Avoid the use of "++" and "--" in combination with other operators. Such may easily lead to mistakes in the expected evaluation order and the side effects that go with it. Its not for the C expert (what standard is? :-). But its pretty good for the beginner/intermediate C programmer. I don't know the price now but last I heard they were selling for all of 5 bucks. Of course if it has to go overseas and they know you rich americans are interested ...:-). See telephone nr and address below if you're still interested. CST Sales,Service and Support Centre for Software Technology Nederlandse Philips Bedrijven B.V. Building HOE 1.15 P.O. Box 80000 5600 JA Eindhoven The Netherlands tel nr. +31 40 743561 +31 40 744696 -- wiskunde: Dutch for mathematics. Literally: Knowledge of certainty wis: certainty kunde: Knowledge Roelof Vuurboom SSP/V3 Philips TDS Apeldoorn, The Netherlands +31 55 432226 domain: roelof@idca.tds.philips.nl uucp: ...!mcvax!philapd!roelof
chris@mimsy.UUCP (Chris Torek) (09/30/89)
In article <19860@mimsy.UUCP> cml@tove.umd.edu (Christopher Lott) writes: >Then there are the "10 Commandments for C Programmers" which I have; >my version was produced by Henry Spencer. (also the author? think so.) Yes. >I have saved all of Chris Torek's tutorials that I have seen, all of >which I can pass on. They are extremely helpful on technical issues; maybe >not so much for style. My `style' is extremely simple: indent -d0 -di0 -nfc1 # 4.3BSD-tahoe indent produces it. >Another good reference, more general, is _The_Elements_of_Programming_Style_, >by Kernighan and Plaugher. (Don't quote me on the authors.) This is also correct (the authors, I mean, as well as the `more general' remark); it points more towards correctness and naming issues than towards finicky points of layout (as I said, mine matches `indent -d0 -di0'). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris