Author Topic: codeblocks c++ thread  (Read 2890 times)


  • Guest
codeblocks c++ thread
« 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.

Online Commaster

  • Almost regular
  • **
  • Posts: 169
Re: codeblocks c++ thread
« Reply #1 on: May 21, 2022, 09:01:45 pm »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9695
Re: codeblocks c++ thread
« Reply #2 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: