C/C++

From HCL
Revision as of 16:01, 16 February 2010 by Root (talk | contribs) (Creating libraries with Autotools)

Jump to: navigation, search

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 = ...
    • define static lib_LIBRARIES = library.a or dynamic lib_LTLIBRARIES = library.la
    • sources (internal C data structures and C++ template classes): library_X_SOURCES = library.h ..., where X = a or la
      • library.h is a precompiled header (contains common headers and symbols), which is to be included in most of source files of the library