为什么VS2015 intellisense在C ++ 11用户定义的文字(UDL)上显示错误

时间:2015-10-03 20:53:01

标签: eclipse c++11 visual-studio-2015 c++14 g++4.9

以下代码可以编译和运行,但VS2015 intellisense显示错误。 g ++& eclipse有同样的问题(编译和运行但显示错误)

有谁知道如何修复它?我尝试在谷歌搜索,但绝望。 错误有点烦人..: - )

#include <iostream>
#include <thread>
#include <chrono>

using namespace std;
using namespace std::literals;
using namespace chrono_literals;

int main()
{
    this_thread::sleep_for(5s);
    cout << "test \n";

    return 0;
}

错误消息:“整数字面上的无效后缀's

非常感谢!

1 个答案:

答案 0 :(得分:1)

您应该添加一些#include语句和namespace引用:

    #include <iostream>
    #include <chrono>
    #include <thread>

    int main()
    {
        using namespace std::literals::chrono_literals;

        std::this_thread::sleep_for(5s);
        std::cout << "test \n";

        return 0;
    }

在您的代码中,未告知编译器使用名称空间std。没有std::literals

,5s不起作用