英文:
No type named 'time_zone' in namespace 'std::chrono'
问题
我正在尝试在MinGW下使用Clang 16.0.4编译一个Windows项目。
结果,我得到了这个错误:
error: no type named 'time_zone' in namespace 'std::chrono'
在我的CMakeLists中,我有这个设置:
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_C_STANDARD 17)
另外,我尝试过将gnu++20
更改为普通的c++20
标准,并使用CMAKE_CXX_EXTENSIONS OFF
,但最终没有任何区别。
我应该怎么做?也许考虑一些非标准的时区替代方案?
英文:
I'm trying to compile a project on windows under MinGW with Clang 16.0.4.
As a result, I get this error:
error: no type named 'time_zone' in namespace 'std::chrono'
In my CMakeLists I have this set:
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_C_STANDARD 17)
Also, I've tried changing that gnu++20
to normal c++20
standard with CMAKE_CXX_EXTENSIONS OFF
, but this doesn't make any difference in the end.
What should I do? Maybe consider some non-standard replacement for time zones?
答案1
得分: 3
你需要使用 g++
13 标准库才能获取 std::chrono::time_zone
。您很可能安装了较旧版本的 g++ 标准库,这是 clang++
默认使用的。
clang++16.0.4
本身提供的标准库(-stdlib=libc++
)也不包括 time_zone
。
选项:
- 安装更新的
g++
并让clang++
使用其标准库。 - 安装
date.h
+tz.h
并使用它。 - 从最新的源代码构建
clang++
及其标准库。这将包括std::chrono::time_zone
。
英文:
You need the g++
13 standard library to get std::chrono::time_zone
. You most likely have an older version of the g++ standard library installed - which is what clang++
uses by default.
The standard library provided by clang++16.0.4 itself (-stdlib=libc++
) does not include time_zone
either.
Options:
- Install a newer
g++
and makeclang++
use its standard library. - Install
date.h
+tz.h
and use that. - Build
clang++
and its standard library from the latest source. That includesstd::chrono::time_zone
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论