Header-only
Appearance
A library, usually in C or C++, is called header-only if the full definitions of all macros, functions and classes comprising the library are visible to the compiler in header, or include-file, form.
The great advantage of a header-only library is that it does not need to be separately compiled, packaged and installed in order to be used. All that is usually required is to define a suitable environment variable to where it resides, and then #include the file(s) into one's application.
The disadvantages include:
- brittleness - any change to the library requires recompilation
- longer compilation times - because the compilation unit must see the implementation of all components in the included file(s), rather than just their interfaces
- code-bloat (this may be disputed) - the necessary use of inline statements in non-class functions can lead to code bloat by over-inlining.
Nonetheless, the header-only form is popular because it avoids the (often much more serious) problem of packaging.