I want to use the header available in c++20.
I am using the most up to date release of cmake.
my CMakeFiles looks like
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")
i am using clang 9 as my compiler.
however i am getting the following error when including :
fatal error: 'format' file not found
#include <format>
i have also used the flag -std=c++2a
, with no effect. In short, i feel i have missed something important here.
Im a little new to cmake, any help?
In the C/C++ ecosystem, the best tool for project configuration is CMake. CMake allows you to specify the build of a project, in files named CMakeLists. txt, with a simple syntax (much simpler than writing Makefiles).
CMake currently does not support C++20 modules. See also the relevant issue in the CMake issue tracker. Note that supporting modules requires far more support from the build system than inserting a new compiler option.
Both C++ CMake tools for Windows and Linux Development with C++ are required for cross-platform CMake development. For more information, see Install the C++ Linux workload in Visual Studio.
According to the C++ compiler support page (archive) on cppreference, none of the mainstream compilers currently support the C++20 <format>
functionalities.
Therefore, you can't currently use #include <format>
. Consider using the {fmt} library for now, on which the C++20 <format>
library is based. It is famous for its high safety and efficiency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With