Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: demone on April 21, 2013, 09:45:13 pm

Title: why no std::thread?
Post by: demone 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.
Title: Re: why no std::thread?
Post by: killerbot on April 21, 2013, 10:09:20 pm
the TDM mingW port indeed does not support std::thread, short : LGPL issues and so on.
Title: Re: why no std::thread?
Post by: demone 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?
Title: Re: why no std::thread?
Post by: Jenna 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.
Title: Re: why no std::thread?
Post by: Alpha 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? ;)
Title: Re: why no std::thread?
Post by: osdt 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
Title: Re: why no std::thread?
Post by: zabzonk 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/ .
Title: Re: why no std::thread?
Post by: demone 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.
Title: Re: why no std::thread?
Post by: xunxun 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.