Re: Support for std::thread in libstdc++

Eli Zaretskii <eliz-mXXj517/[email protected]>
Newsgroups gmane.comp.gnu.mingw.user
Message-ID <[email protected]>
> From: Keith Marshall <[email protected]>
> Date: Tue, 12 Mar 2019 22:06:06 +0000
> 
> On 12/03/19 15:41, Eli Zaretskii wrote:
> > Does anyone know what happens if a program is compiled that uses this
> > class?  Will it fail to compile, or abort at run time, or something
> > else?
> 
> I reviewed some of our historical archives, (my own local copies); it
> appears that, if GCC has been built with the win32 thread model, the
> class definition isn't exposed, so you get a compile time failure,
> diagnosed as "thread is not a member of std", or some such.

Yes, you are right.  For the record: the simple test program below
produces the following diagnostics:

  D:\usr\eli\data>g++ -c ./threaded-hello.cc
  ./threaded-hello.cc: In function 'int main()':
  ./threaded-hello.cc:12:8: error: 'thread' is not a member of 'std'
     std::thread t1(call_from_thread);
	  ^~~~~~
  ./threaded-hello.cc:12:8: note: suggested alternative: 'tera'
     std::thread t1(call_from_thread);
	  ^~~~~~
	  tera
  ./threaded-hello.cc:15:3: error: 't1' was not declared in this scope
     t1.join();
     ^~
  ./threaded-hello.cc:15:3: note: suggested alternative: 'tm'
     t1.join();
     ^~
     tm

Here's source code of the program I used:

#include <iostream>
#include <thread>

//This function will be called from a thread

void call_from_thread() {
  std::cout << "Hello, World" << std::endl;
}

int main() {
  //Launch a thread
  std::thread t1(call_from_thread);

  //Join the thread with the main thread
  t1.join();

  return 0;
}

_______________________________________________
MinGW-Users mailing list
[email protected]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.