Codeblocks miért ír errort?
Ennél az egyszerű multithreades programnál:
#include <string>
#include <iostream>
#include <thread>
using namespace std;
//The function we want to make the thread run.
void task1(string msg)
{
cout << "task1 says: " << msg;
}
int main()
{
// Constructs the new thread and runs it. Does not block execution.
thread t1(task1, "Hello");
//Makes the main thread wait for the new thread to finish execution, therefore blocks its own execution.
t1.join();
}
a következő 3 errort adja: 17.sor, thread was not declared in this scope, 17.sor, excepted ";" before t1, 20. sor, t1 was not declared in this scope.
Ezt úgy sikerült elérnem, hogy a compilernél beállítottam hogy fogadja el a c++11 szabványt is, viszont a fent említett 3 error az eredménye.





Ahonnan valszeg te is másoltad a kódot:
"On GCC, compile with -std=c++0x -pthread.
This should work for any operating-system, granted your compiler supports this (C++11) feature"
Kapcsolódó kérdések:
Minden jog fenntartva © 2025, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!