Difference between revisions of "C/C++"

From HCL
Jump to: navigation, search
(Coding)
(Coding)
Line 1: Line 1:
 
== Coding ==
 
== Coding ==
* C++ programming style is preferrable. For example, in variable declarations, pointers and references should have their reference symbol next to the type rather than to the name. Variables should be initialized where they are declared, and should be declared where they are used.
+
* C++ programming style is preferrable. For example, in variable declarations, pointers and references should have their reference symbol next to the type rather than to the name. Variables should be initialized where they are declared, and should be declared where they are used. For more details, see [http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml Google C++ Style Guide]
 
* [http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS One-true-brace ident style]
 
* [http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS One-true-brace ident style]
 
* [http://en.wikipedia.org/wiki/Pragma_once Coding header files]
 
* [http://en.wikipedia.org/wiki/Pragma_once Coding header files]

Revision as of 09:51, 20 May 2010

Coding

  • C++ programming style is preferrable. For example, in variable declarations, pointers and references should have their reference symbol next to the type rather than to the name. Variables should be initialized where they are declared, and should be declared where they are used. For more details, see Google C++ Style Guide
  • One-true-brace ident style
  • Coding header files
  • Learn from examples and use coding approaches from third-party software

Commenting

  • Place Doxygen comments in header files (before declarations of namespaces/classes/structs/typedefs/macros) and main source files (for documenting tools and tests)
  • Use double forward slash for short comments in the code

C++

General