没有在命名空间 ‘std::chrono’ 中找到名为 ‘time_zone’ 的类型。

huangapple go评论91阅读模式
英文:

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 make clang++ use its standard library.
  • Install date.h + tz.h and use that.
  • Build clang++ and its standard library from the latest source. That includes std::chrono::time_zone.

huangapple
  • 本文由 发表于 2023年7月7日 02:14:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76631536.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定