C and C++ Style Guides
This is an archive of style guides for C and C++ code. Also archived
here are some documents that discuss the value and utility of style
guides. The documents are not listed in any particular order.
For history buffs, this collection includes two style guides that are
based on work done at Bell Labs Indian Hill (the site in Naperville,
Illinois where the 5ESS digital switch is developed).
The list includes original versions whenever possible. If you have a
working formatter (either LaTeX or troff), the original versions are
almost certainly the best. If you've never heard of those old
software packages, try the PDF or HTML versions.
- Original Indian Hill guide with annotations by H. Spencer
15 pages;
HTML,
PDF,
troff
- Indian Hill C style guide, as amended at UofT, UW, and elsewhere
28 pages;
HTML,
PDF,
troff
- C++ coding rules from Ellemtel (Swedish Telecom) by
Mats Henricson
and Erik Nyquist.
68 pages;
HTML,
PDF
This was expanded into a book called Industrial Strength C++ by Mats
Henricson and published by Prentice-Hall in 1996 (ISBN 0131209655).
The book is no longer in print but the text is available here:
http://hem.passagen.se/erinyq/industrial/
- C++ style guide from Wildfire Communications
About 46 pages;
HTML
- C++ Coding Standard by Todd Hoff
About 64 pages;
HTML
- Document about C++ code inspections by J. Baldwin
21 pages;
PDF
- Notes on programming in C by Rob Pike
5 pages;
HTML,
PDF
- C porting guide by A. Dolenc, A. Lemmke, and D. Keppel
22 pages;
HTML,
PDF,
LaTeX
- Ten Commandments for C programmers by Henry Spencer
Original (1 page):
HTML,
PDF,
troff;
and annotated (several pages):
HTML
- Henry Spencer's writings on code stealing, reuse
11 pages;
HTML,
PDF,
troff
- A paper about checking for failure codes by Ian Darwin and Geoff
Collyer, a paper presented at the January 1985 Usenix
conference.
19 pages;
HTML,
PDF
- Words of wisdom from Henry Spencer and Geoff Collyer
about the appropriate use of #ifdefs, a paper
presented at the Summer 1992 Usenix conference.
13 pages;
PDF
- Tim Ottinger's rules for naming variables and classes.
About 7 pages;
HTML
- Cstyle document from ESA, Australia
About 9 pages;
plain-text
- Coding standard from the GNU people as of 10 Feb 89
About 5 pages;
plain-text
- Some discussions about style documents (from Usenet, 1993)
About 8 pages;
plain-text
- More discussion about style documents (from Usenet, 1989)
About 6 pages;
plain-text
- Linux Kernel coding style from Linus Torvalds.
About 5 pages;
plain-text
- The C Style Guide and Programming Guidelines from
The C Kernel pages
by Peter van der Vlugt.
About 24 pages;
PDF
- C++ style advice called "The Tao of Coding" from Koen
Witters.
About 12 pages;
HTML
Finally, if you would like a quick way to develop your own style guide
for C, C++, or Java, Sven Rosvall offers a style-document generator.
His page lets you make some choices about various constructs, and the
generator builds a HTML document for you.
http://www.rosvall.ie/CSG/
Home page