Difference between revisions of "C/C++"
From HCL
Line 10: | Line 10: | ||
== C++ == | == C++ == | ||
* [http://developers.sun.com/solaris/articles/mixing.html Mixing C/C++] | * [http://developers.sun.com/solaris/articles/mixing.html Mixing C/C++] | ||
+ | * Provide main API in C | ||
+ | * Use plain C unless you need flexible data structures or [[STL]]/[[Boost]] functionality | ||
* [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] |
− | |||
== General == | == General == |
Revision as of 18:37, 5 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
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