C/C++ Thread ve Chrono hatası

Katılım
20 Haziran 2022
Mesajlar
166
Çözümler
1
Daha fazla  
Sistem Özellikleri
İşletim sistemi: Windows 10 Home 64 Bit.
Sistem üreticisi: Toshiba.
Sistem modeli: Satallite l505.
İşlemci: Intel(R) Core (tm) i3 CPU M330 @ 2.13GHz (4cpus),~2.1GHz
Ekran kartı: Intel HD Graphics.
Bellek: 4096 RAM.
Disk belleği dosyası: 3594MB kullanıldı, 1708MB kaldı.
DirectX sürümü: DirectX 12.
Cinsiyet
Erkek
C++:
#include <iostream>
#include <windows.h>
#include <thread>
#include <vector>
#include <numeric>
#include <chrono>
#include <ctime>

using namespace std;

void simulateFPS() {
 srand(static_cast<unsigned int>(time(nullptr)));
 vector<int> fpsValues;
 int averageFPS = 60;
 const int sampleSize = 5;

 while (true) {
 int currentFPS = rand() % 91 + 30;
 fpsValues.push_back(currentFPS);

 this_thread::sleep_for(chrono::seconds(sampleSize));

 if (!fpsValues.empty()) {
 double sum = accumulate(fpsValues.begin(), fpsValues.end(), 0.0);
 averageFPS = sum / fpsValues.size();
 }

 if (currentFPS < averageFPS * 0.75) {
 INPUT input[4] = {};
 input[0].type = INPUT_KEYBOARD;
 input[0].ki.wVk = VK_LWIN;
 input[1].type = INPUT_KEYBOARD;
 input[1].ki.wVk = VK_CONTROL;
 input[2].type = INPUT_KEYBOARD;
 input[2].ki.wVk = VK_SHIFT;

 SendInput(3, input, sizeof(INPUT));

 input[0].ki.dwFlags = KEYEVENTF_KEYUP;
 input[1].ki.dwFlags = KEYEVENTF_KEYUP;
 input[2].ki.dwFlags = KEYEVENTF_KEYUP;
 SendInput(3, input, sizeof(INPUT));
 }
 }
}

int main() {
 ShowWindow(GetConsoleWindow(), SW_HIDE);
 simulateFPS();
 return 0;
}

Şu hataları veriyor: "
[Error] 'std: This_thread' has not been declared,
[Error] 'std: Chrono' has not been declared"
 
C++:
using namespace std::chrono_literals;
ekleyip deneyebilir misin?
 
Bi deniyim

12 22 C:\Users\lenovo\Documents\c++12 37 C:\Users\lenovo\Documents\c++\EKRANKARTIRESETZAM.cpp [Error] expected namespace-name before ';' token\EKRANKARTIRESETZAM.cpp [Error] 'chrono_literals' is not a namespace-name
 
İfadeler: 900
Bu siteyi kullanmak için çerezler gereklidir. Siteyi kullanmaya devam etmek için çerezleri kabul etmelisiniz. Daha Fazlasını Öğren.…