简体   繁体   中英

how to use c++20 in cmake project

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM