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
- Indian Hill C style guide, as amended at UofT, UW, and elsewhere
- C++ coding rules from Ellemtel (Swedish Telecom) by
and Erik Nyquist.
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:
- C++ style guide from Wildfire Communications
About 46 pages;
- C++ Coding Standard by Todd Hoff
About 64 pages;
- Document about C++ code inspections by J. Baldwin
- Notes on programming in C by Rob Pike
- C porting guide by A. Dolenc, A. Lemmke, and D. Keppel
- Ten Commandments for C programmers by Henry Spencer
Original (1 page):
and annotated (several pages):
- Henry Spencer's writings on code stealing, reuse
- A paper about checking for failure codes by Ian Darwin and Geoff
Collyer, a paper presented at the January 1985 Usenix
- Words of wisdom from Henry Spencer and Geoff Collyer
about the appropriate use of #ifdefs, a paper
presented at the Summer 1992 Usenix conference.
- Tim Ottinger's rules for naming variables and classes.
About 7 pages;
- Cstyle document from ESA, Australia
About 9 pages;
- Coding standard from the GNU people as of 10 Feb 89
About 5 pages;
- Some discussions about style documents (from Usenet, 1993)
About 8 pages;
- More discussion about style documents (from Usenet, 1989)
About 6 pages;
- Linux Kernel coding style from Linus Torvalds.
About 5 pages;
- The C Style Guide and Programming Guidelines from
The C Kernel pages
by Peter van der Vlugt.
About 24 pages;
- C++ style advice called "The Tao of Coding" from Koen
About 12 pages;
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.