|
Unit Conversion and Dimensional Analysis Library 3.6.1
A compile-time, header-only C++23 dimensional-analysis library
|
For embedded or freestanding builds where <iostream> is unwanted, units can be compiled without it. Define UNIT_LIB_DISABLE_IOSTREAM before including the library. The unit types, arithmetic, conversions, and name()/abbreviation() all continue to work; only the stream/string rendering is removed.
Defining the macro drops the operator<< overloads, to_string, and the <clocale>/<iostream> includes. Everything else is unaffected.
name() and abbreviation() return const char* and do not depend on <iostream> or <string>, so they remain available for producing a label without pulling in the streaming machinery.
Per translation unit — define the macro before the first units include:
Project-wide via CMake — set the UNITS_DISABLE_IOSTREAM option, which defines the macro on the interface target for every consumer:
Note — embedded builds. On platforms whose system headers define macros that clash with the SI abbreviations, also see the macro-clash guidance (#undef pascal on Windows; several single-letter #undefs on some ARM toolchains). Disabling iostream is commonly combined with those on embedded targets. The related configuration macros are listed in configuration.