Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » standard thread ( error: 'thread' was not declared in this scope)
standard thread [message #46719] Wed, 20 July 2016 11:04 Go to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hi,

I tried to use the standard thread library and get error:

Quote:
error: 'thread' was not declared in this scope


#include <iostream>
#include <thread>

void myfunction()
{
	int nbr = 0;
	for(int i=0; i<1000; i++)
		nbr += (i%2 == 0)?1:0;
}

int main(int argc, const char *argv[])
{
	std::thread th(myfunction);
	th.join();
	
	return 0;
}


Do I need to change build parameter? add environment variable?

Thanks in advanced
Re: standard thread [message #46720 is a reply to message #46719] Wed, 20 July 2016 11:39 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1778
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi ratah,

Quick guess: Are you building with C++11? Check if you have --std=c++11 compiler option in your build method. Also, what compiler are you using? Some older GCC had only partial support for C++11, that could cause similar problem.

Best regards,
Honza
Re: standard thread [message #46721 is a reply to message #46719] Wed, 20 July 2016 14:27 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
I do use the default compiler which is part of the upp package.
MinGW-W64-builds-4.2.0
Re: standard thread [message #46725 is a reply to message #46721] Wed, 20 July 2016 17:13 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1778
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

ratah wrote on Wed, 20 July 2016 14:27
I do use the default compiler which is part of the upp package.
MinGW-W64-builds-4.2.0


Oops, that is the problem. Reasonable support of C++11 is available only since 4.7...

The mingw in bundled builds will have to be upgraded. It doesn't make any sense to put non-C++11 compiler to sources that require C++11 Confused

Honza
Re: standard thread [message #46727 is a reply to message #46725] Wed, 20 July 2016 20:08 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 735
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello,

Your thread code seems to compile fine on my setup (Windows 10 + latests U++ with bundled compiler). Can I ask you something - what is your version of upp?

Please notice that currently in prototable version we bundle compiler that is consistent with C++11.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Wed, 20 July 2016 20:08]

Report message to a moderator

Re: standard thread [message #46736 is a reply to message #46727] Thu, 21 July 2016 10:11 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hi,
I ve got the latest version of upp and get the same case with MingWin Sad

I test MSC15 and got this error:

----- test_thread ( MAIN MSC15 DEBUG DEBUG_FULL BLITZ WIN32 MSC )
test_thread.cpp
c:\program files (x86)\microsoft visual studio 14.0\vc\include\crtdefs.h(10): fatal error C1083: Cannot open include file: 'corecrt.h': No such file or directory
test_thread: 1 file(s) built in (0:00.07), 78 msecs / file, duration = 78 msecs, parallelization 0%


I do add this in the include paths according to this https://social.msdn.microsoft.com/Forums/vstudio/en-US/86bc5 77b-528c-469c-a506-15383a44c111/missing-corecrth-from-the-de fault-include-folder-for-vs215?forum=vcgeneral

C:/Program Files (x86)/Windows Kits/10/Include/10.0.10150.0/ucrt


Best regards,
Ratah
Re: standard thread [message #48217 is a reply to message #46719] Tue, 06 June 2017 10:08 Go to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Thread chk, recv1, recv2;
Thread work, workX;
Control() {
That is how I declared the 5 threads

Just declare them before your main app

Neil

[Updated on: Tue, 06 June 2017 10:22]

Report message to a moderator

Previous Topic: MDNS (Apple's Bonjour)
Next Topic: Send/receive files with SCP and launch commands with SSH
Goto Forum:
  


Current Time: Tue Oct 20 07:21:34 CEST 2020

Total time taken to generate the page: 0.01412 seconds