C++11 实验函数

标签 c++ c++11

<分区>

每次我使用 C++11 提供的新类之一(如 chrono.h)并使用 GCC 编译它时,它都会警告我 C++11 函数仍处于试验阶段,必须使用特殊标志启用才能使用。

写这篇文章的时候已经是 2014 年底了,为什么 GCC 在至少 3.5 年后仍然将 C++11 标记为“实验性”,这么多年过去了,C++11 为我们提供的一些功能仍然存在没有实现?

如果是这样,那怎么会呢?

代码:

#include <chrono>
#include <thread>
int main()
{
    std::this_thread::sleep_for(std::chrono::milliseconds(3000));
    return 0;
}

编译器行: g++ Source.cpp -o test.exe

海湾合作委员会版本: g++(x86_64-posix-seh-rev0,由 MinGW-W64 项目构建)4.9.2 版权所有 (C) 2014 Free Software Foundation, Inc.

海湾合作委员会吐出: C:/Program Files/mingw-w64/x86_64-4.9.2-posix-seh-rt_v3-rev0/mingw64/x86_64-w64-mingw32/include/c++/bits/c++0x_warning.h:32: 2: error: #error 此文件需要 G 编译器和库支持 ISO C++ 2011 标准。此支持目前处于试验阶段,必须使用 -std=c++11 或 -std=gnu++11 编译器选项启用。

最佳答案

Once I add. '-std=c++11' to the compiler options I no longer get the error/warning message but I was already aware of that. I was puzzled as to why it did give me a warning without adding it. Shouldn't the current std on GCC be C++11 already? Why is this still not the case?

现有的软件和构建系统使用默认设置,并期望它们保持相当稳定。 GCC 不会在每次有新标准或功能可用时简单地更新默认设置。

如果您需要标准的特定版本,则应明确指定。

关于C++11 实验函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27043477/

相关文章:

c++ - 通过属性 getter 访问 std::map 返回垃圾值

c++ - 填充数组的数组

c++ - 为什么我必须对用户定义的文字使用 long double?

c++ - 在 C++ 的元编程中保护从非 const-volatile 类型到 const-volatile 的赋值的正确方法是什么?

c++ - 按值传递与 const & 和 && 重载

c++ - 我可以在哪里定义 MFC 应用程序中的全局变量?

c++ - 使库函数使用从库类派生的类

c++ - 初始化静态成员导致 `Missing type specifier - int assumed.`

c++ - 为什么 std::move 不在默认 move 构造函数中将源变量更改为默认值?

c++ - 字符串 vector 到 istringstream