Search code examples
c++c++98fmt

Do any old versions of {fmt} support C++98?


I work with a legacy compiler (C++98) and would like to use {fmt} to format strings into a std::ostream. Is there any version of {fmt} that works with C++98, or has C++11 always been a requirement?

I tried using godbolt, adding -std=c++98 to the compile flags, using the oldest tag in GitHub and got a very specific error:

error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.


Solution

  • {fmt} 4.1 is the last version that supported C++98. Starting from version 5.0 {fmt} requires a subset of C++11, quoting release notes:

    Added a requirement for partial C++11 support, most importantly variadic templates and type traits, and dropped FMT_VARIADIC_* emulation macros. Variadic templates are available since GCC 4.4, Clang 2.9 and MSVC 18.0 (2013). For older compilers use {fmt} version 4.x which continues to be maintained and works with C++98 compilers.