Difference between revisions of "C/C++"
From HCL
Line 14: | Line 14: | ||
* [http://en.wikipedia.org/wiki/Template_metaprogramming Template C++] is preferrable from the point of view of runtime performance | * [http://en.wikipedia.org/wiki/Template_metaprogramming Template C++] is preferrable from the point of view of runtime performance | ||
* Mind the life cycle of objects: [http://en.wikipedia.org/wiki/Default_constructor Default constructor] [http://en.wikipedia.org/wiki/Copy_constructor Copy constructor], [http://en.wikipedia.org/wiki/Destructor_(computer_science) Destructor] | * Mind the life cycle of objects: [http://en.wikipedia.org/wiki/Default_constructor Default constructor] [http://en.wikipedia.org/wiki/Copy_constructor Copy constructor], [http://en.wikipedia.org/wiki/Destructor_(computer_science) Destructor] | ||
+ | * [http://www.gnu.org/software/hello/manual/automake/Libtool-Convenience-Libraries.html Force C++ linking] | ||
== General == | == General == |
Revision as of 04:54, 17 March 2010
Contents
Coding
- Coding header files
- One-true-brace ident style
- 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++
- Mixing C/C++
- Provide main API in C
- Use plain C unless you need flexible data structures or STL/Boost functionality
- Template C++ is preferrable from the point of view of runtime performance
- Mind the life cycle of objects: Default constructor Copy constructor, Destructor
- Force C++ linking
General
- Don't use non-standard functions, like itoa
- Handling program arguments (avoid
argp
since it is not supported on many platforms) - Dynamic loading of shared libraries