Difference between revisions of "C/C++"
From HCL
Line 16: | Line 16: | ||
== General == | == General == | ||
* Don't use non-standard functions, like [http://en.wikipedia.org/wiki/Itoa itoa] | * Don't use non-standard functions, like [http://en.wikipedia.org/wiki/Itoa itoa] | ||
− | * [http://www.gnu.org/software/libc/manual/html_node/Program-Arguments.html Handling program arguments] | + | * [http://www.gnu.org/software/libc/manual/html_node/Program-Arguments.html Handling program arguments] (avoid <code>argp</code> since it is not supported on many platforms) |
* [http://en.wikipedia.org/wiki/Dynamic_loading Dynamic loading of shared libraries] | * [http://en.wikipedia.org/wiki/Dynamic_loading Dynamic loading of shared libraries] |
Revision as of 08:53, 23 February 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++
- Template C++ is preferrable from the point of view of runtime performance
- Use plain C unless you need flexible data structures or STL/Boost functionality
- Provide main API in C
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