1

下面的代码可以编译运行,但是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' 无效”

非常感谢!

4

1 回答 1

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;
    }

在您的代码中,没有告诉编译器使用 namespace std。没有 5s 就不行std::literals

于 2015-10-03T22:06:02.050 回答