Header Only Cee Plus Plus Packages

Many libraries in CeeLanguage and CeePlusPlus can be defined entirely in header files. Examples include many but not all of the BoostLibraries.

It is especially convenient if a library or package can be expressed completely in a CeeCeePlusPlus header file. (.h .hh .hpp .hxx .H), without any accompanying source file (.c .cc .cpp .cxx .C). that must be compiled to an object file (.o .obj) and then linked.

This is because many C/C++ UNIX-like build systems have MakeDepend, which can automatically deduce header file dependencies. You add a header, and it automatically gets handled properly by build tools such as make.

However, very few people use MakeLinkDepend. Therefore, to use a library which consists of more than a header, you typically need to add the

#include "package.hh"
and then add package.o or libpackage.a to the Makefile. And then, you may need to add rules to build the object files or libraries.

Java is much better behaved in this way.


Techniques for creating header only packages:

for singletons is:

      class foo_c { ... };

inline foo_c& foo_singleton() { static foo_c global_foo("constructor parms"; return global_foo; }

A slightly different flavour makes the singleton a class static function.


CategoryCpp


EditText of this page (last edited March 24, 2012) or FindPage with title or text search