The Google C++ Style Guide

10 Nov 2008

I'm not quite sure how I bumped into this but the kindly engineers at Google posted their C++ style guide. It's a good one. It lists the rule, followed by the pros and cons, and the more explanation on the final decision. Some "highlights":

  • No RTTI. No shocker here. Does anyone actually use this "feature"?
  • printf preferred over streams! Not sure I agree with this one but they make some good points
  • No exceptions! Certainly an API shouldn't have exceptions. Internally however? They make a good point that one missed catch and your application coredumps
  • Use int and only int, unless of course you can't. Thank god someone else knows that the unsigned and short types dont' do what you think they do!
  • Use of the Boost libraries is restricted to CompressedPair, PtrContainer, Array, PropertyMap, part of Iterator and The Boost Graph Library. It's not clear if the boost libraries which are part of TR1 are allowed or not. I've spoken to quite a few companies that have restricted the use of Boost, since many of the libraries are so way out and overdone.

The rest is sensible and a good read for novice and experienced C++ developers alike.

Comment 2008-11-12 by None

I wish they released this earlier. :)