Issue C1083: cannot open include file: 'chrono': no such file or directory pops out

大憨熊 提交于 2019-12-10 19:07:33

问题


I'm trying to make a program that makes 6 numbers come out randomly.

This is my .pro file

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Lotto
TEMPLATE = app

CONFIG += c++11

SOURCES += main.cpp\
        mainwindow.cpp \
    lottogenerator.cpp

HEADERS  += mainwindow.h \
    lottogenerator.h

FORMS    += mainwindow.ui

This is my .h file

#ifndef LOTTOGENERATOR_H
#define LOTTOGENERATOR_H


#include <string>
#include <random>
#include <array>
#include <chrono>

class LottoGenerator
{
public:
    typedef std::chrono::high_resolution_clock myclock;

    LottoGenerator();

    std::array<int, 6> get();

private:
    int rand();

    std::mt19937 *engine;
    std::uniform_int_distribution<int> distribution;

    myclock::time_point beginning = myclock::now();
};

#endif // LOTTOGENERATOR_H

This is my .cpp file.

#include "lottogenerator.h"

LottoGenerator::LottoGenerator()
    : distribution(1,45)
{
    myclock::duration d = myclock::now() - beginning;
    unsigned int seed = d.count();

    engine.seed(seed);
}

std::array<int, 6> LottoGenerator::get()
{
    std::array<int, 6> numbers;

    numbers[0] = rand();
    numbers[1] = rand();
    numbers[2] = rand();
    numbers[3] = rand();
    numbers[4] = rand();
    numbers[5] = rand();

    return numbers;
}

int LottoGenerator::rand()
{
    return distribution(engine);
}

and when I run, "C1083: cannot open include file: 'chrono': no such file or directory" pops out.

It would be grateful if you could help:)


回答1:


You are using a MSVC version that is too old. The error originates in the compiler, not in Qt Creator.



来源:https://stackoverflow.com/questions/31790190/issue-c1083-cannot-open-include-file-chrono-no-such-file-or-directory-pops

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!