Language
Rule
US-English is used in all documents and for al filenames, comments, variables, types, etc.
Rationale
English is a logical choice in an international world with international customers and employees from over all the world. The choice between Britisch and American English is arbritrary. The main point is to choose one and be consistent. US-English is choosen because the American dominance in ICT books and companies.
See Canadian, British and American Spelling for spelling differences.
Examples: Use centimeter (not centimetre), center (not centre), color (not colour), specialization (not specialisation), standardize (not standardise), summarize (not summarise).
Pointer asterisk position
Rule
For type declarations, put the asterisk adjacent the type name.
So use int* a
(not int *a
, int * a
, or int*a
).
Rationale
As Stroustrup describes, “it is not about right and wrong, but about style and emphasis”. He also states that:
A “typical C programmer” writes int *p; and explains it “*p is what is the int” emphasizing syntax.
A “typical C++ programmer” writes int* p; and explains it “p is a pointer to an int” emphasizing type.
See also discussion 1 and discussion 2 at stackoverlow.
filename or file name?
Rule
…
Rationale
From a lanuage perspective, the original form of the word was “file name”, as in the name of a file. These days (and probably for a good few years), the compound “filename” is widely accepted and perhaps most commonly used. Either is of course perfectly acceptable). (Reference English Language & Usage)
When writing variable names in code, lower camel case is recommended and fileName is used and NOT filename. This approach adds consistency when several parameters (fields, variables..) are used in the same method (class..) and the with same prefix “file”. I.e. fileName and fileSize instead of filename and filesize. (Reference StackOverflow)
File extensions
The Google style guide seems to suggest .cc, but provides no explanation.
Historically, the suffix for a C++ source file was .C.
Different users adopted different solutions: .cc, .cpp, .cxx
t’s usually a good idea to distinguish between the headers which can be used in C (.h) and those which cannot (.hh or .hpp)
a lot of users prefer keeping the template sources and the inline functions in a separate file. Which, while strictly speaking a header file, tends to get yet another set of conventions (.inl, .tcc and probably a lot of others).
At the end of the day it doesn’t matter because C++ compilers can deal with the files in either format. If it’s a real issue within your team, flip a coin and move on to the actual work.