提问人:Physicist 提问时间:8/27/2023 最后编辑:Ted LyngmoPhysicist 更新时间:8/27/2023 访问量:75
clang编译器中的C++ 20
C++ 20 in clang compiler
问:
我想在我的 Windows 10 操作系统中使用 clang 编译器,所以我下载了 Cygwin 并安装了它。通常编译可以工作,但是当我设置标志(或-std = c ++ 2a)时,clang会产生一些错误:-std=c++20
#include <iostream>
using namespace std;
int main() {
cout << "Hello world!!!" << endl;
return 0;
}
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/iostream:39:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ostream:38:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ios:42:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/ios_base.h:41:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/locale_classes.h:40:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/string:55:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.h:40:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ext/alloc_traits.h:34:
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/alloc_traits.h:263:4: error:
no member named 'construct_at' in namespace 'std'; did you mean
'construct'?
std::construct_at(__p, std::forward<_Args>(__args)...);
^~~~~
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/alloc_traits.h:360:2: note:
'construct' declared here
construct(_Alloc& __a, _Tp* __p, _Args&&... __args)
^
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/alloc_traits.h:518:4: error:
no member named 'construct_at' in namespace 'std'; did you mean
'construct'?
std::construct_at(__p, std::forward<_Args>(__args)...);
^~~~~
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/alloc_traits.h:511:2: note:
'construct' declared here
construct(allocator_type& __a __attribute__((__unused__)), _Up* __p,
^
2 errors generated.
在VM中的Ubuntu上安装的Clang可以正常工作,那么这里可能有什么问题?我想是环境变量,但如果这可能是问题,如何正确设置它们?
我尝试使用 Cygwin 工具重新安装 clang,以检查其他版本或源代码库/编译器的工作原理。我检查了这个问题是否先于其他问题出现。我希望说明如何在 Windows 10 上准确正确地安装 clang 到所有想要工作的东西,但我没有找到它。
答: 暂无答案
评论
cpp #include <iostream> using namespace std; int main() { cout<<"Hello world!!!"<<endl; return 0; }
clang++ -std=c++20