Author Topic: why no std::thread?  (Read 27307 times)

Offline demone

  • Multiple posting newcomer
  • *
  • Posts: 36
why no std::thread?
« on: April 21, 2013, 09:45:13 pm »
I guess why code::blocks used a GCC package with no thread support under windows.

If I try to compile the following:

#include <iostream>
#include <thread>

void foo(){
std::cout<<"hello thread"<<std::endl;
}

int main(){
    std::thread myT(foo);
    myT.join();
    return 0;
}

I get the error "thread is not a member of std"

I already have the flag
"-std=C++11"
in compile options.
« Last Edit: April 21, 2013, 09:49:52 pm by demone »
processor: Intel Core 2 Quad.
ram: 4 GB
os: Vista
gfx card: Ati Radeon HD 5570

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: why no std::thread?
« Reply #1 on: April 21, 2013, 10:09:20 pm »
the TDM mingW port indeed does not support std::thread, short : LGPL issues and so on.

Offline demone

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: why no std::thread?
« Reply #2 on: April 21, 2013, 10:10:51 pm »
oh my bad :( that's really freaking. Ok I have than to swap to Linux partition.
is there any chance to add support for std::thread ever in GCC at this point?
processor: Intel Core 2 Quad.
ram: 4 GB
os: Vista
gfx card: Ati Radeon HD 5570

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: why no std::thread?
« Reply #3 on: April 21, 2013, 10:15:39 pm »
oh my bad :( that's really freaking. Ok I have than to swap to Linux partition.
is there any chance to add support for std::thread ever in GCC at this point?

That's not the right place to ask.
We do not build vompilers just an IDE, that works with many compilers.
We ship with a TDM's gcc on windows to make it easy to start coding for beginners (and most other users) without the need to explicitely download a compiler.

So you as user are free to use any supported compiler, with or without std:thread-support.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: why no std::thread?
« Reply #4 on: April 22, 2013, 12:13:46 am »
We do not build vompilers just an IDE, that works with many compilers.
That sounds scary... if I install one, will it suck the blood from my computer? ;)

Offline osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: why no std::thread?
« Reply #5 on: April 22, 2013, 12:40:42 am »
That sounds scary... if I install one, will it suck the blood from my computer? ;)
You've never heard of garlic AV suite? The first AV solution at all?

- osdt

zabzonk

  • Guest
Re: why no std::thread?
« Reply #6 on: April 22, 2013, 10:15:57 am »
For those that want std::thread, the MinGW-builds implementation of GCC at provides pretty good support, and works just fine with C::B - I've got a short blog article about it at http://latedev.wordpress.com/2013/02/24/investigating-c11-threads/ .

Offline demone

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: why no std::thread?
« Reply #7 on: April 22, 2013, 01:26:46 pm »
IN particular you may be interested in one of those 2 pakcages from mingw-builds

GCC 4.8.0 32-bit => stack unwinding sjlj & thread support from POSIX
http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.0/32-bit/threads-posix/sjlj/x32-4.8.0-release-posix-sjlj-rev2.7z/download

GCC 4.7.1 32-bit => stack unwinding sjlj & thread support from POSIX
http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.7.1/32-bit/threads-posix/sjlj/x32-4.7.1-release-posix-sjlj-rev0.7z/download

there are other packages as well ^^

they works fine with C::B.
processor: Intel Core 2 Quad.
ram: 4 GB
os: Vista
gfx card: Ati Radeon HD 5570

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: why no std::thread?
« Reply #8 on: April 22, 2013, 02:16:13 pm »
My origin patch was modified by Kai and has been committed to gcc.
http://www.mail-archive.com/mingw-w64-public@lists.sourceforge.net/msg03269.html

But you must use posix thread and winpthread to enable the feature.
Regards,
xunxun