Code::Blocks Forums

User forums => Help => Topic started by: Salih2003 on May 21, 2022, 02:41:55 pm

Title: codeblocks c++ thread
Post by: Salih2003 on May 21, 2022, 02:41:55 pm
Hello. I was learning the thread library of c++. I wrote a code like this.
#include <iostream>
#include <thread>
#include <clocale>
using namespace std;

void print(string message)
    cout << message << endl;

int main()
    thread th1(print,"test");
    return 0;

C++17 flag is raised. However, I am getting an error like this:

||==== Build: Debug in console (compiler: GNU GCC Compiler) ===|
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\CodeBlocks\console\main.cpp||In function 'int main()':|
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\CodeBlocks\console\main.cpp|14|error: 'thread' was not declared in this scope|
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\CodeBlocks\console\main.cpp|4|note: 'std::thread' is defined in header '<thread>'; did you forget to '#include <thread>'?|
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\CodeBlocks\console\main.cpp|17|error: 'th' was not declared in this scope; did you mean 'tm'?|
||==== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===

Why is this problem?
my computer system:
intel core i2 duo 32bit
3gb ram
windows 7
GPU: none.
Since I don't know English, I used google translate.
Title: Re: codeblocks c++ thread
Post by: Commaster on May 21, 2022, 09:01:45 pm
This should help:,9996.0.html
Title: Re: codeblocks c++ thread
Post by: MortenMacFly on May 22, 2022, 05:29:29 am
This should help:,9996.0.html
...this is true.

Please ask such questions not in the forum that is dedicated to the development of the IDE "Code::Blocks" but in a standard C/C++ forum.

Topic locked.