Difference between revisions of "C/C++"

From HCL
Jump to: navigation, search
Line 11: Line 11:
 
* [http://developers.sun.com/solaris/articles/mixing.html Mixing C/C++]
 
* [http://developers.sun.com/solaris/articles/mixing.html Mixing C/C++]
 
* [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
* Use plain C unless you need flexible data structures or STL/Boost functionality
+
* Use plain C unless you need flexible data structures or [[STL]]/[[Boost]] functionality
 
* Provide main API in C
 
* Provide main API in C
  

Revision as of 14:09, 10 February 2010

Coding

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

Creating libraries with Autotools

  • Prepare two sets of headers:
    • includes (for the include directory): include_HEADERS = ...
    • sources (internal C data structures and C++ template classes): library_SOURCES = library.h ...
      • library.h is a precompiled header (contains common headers and symbols), which is to be included in most of source files of the library