Jump to content

  • Log In with Google      Sign In   
  • Create Account


Will the library thread.h in C++11 will cause cross-platform problems?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 cyberspace009   Members   -  Reputation: 179

Like
0Likes
Like

Posted 29 April 2014 - 08:52 AM

I'm making a game using Visual studio 2012. I was using a library thread.h or <thread> to make my threads, but then I found out that I was using a piece of C++11 library. Will this cause issues in cross-platform? Thanks.  



Sponsor:

#2 SeraphLance   Members   -  Reputation: 1313

Like
3Likes
Like

Posted 29 April 2014 - 09:11 AM

Right now, I think the general rule of thumb with C++11 is "If it works in VS2012, it works anywhere".  Both clang and gcc (the other two major C++ compilers) are pretty much strictly ahead of VS in C++11.

 

However, I believe you need the correct compiler switches on the other platforms for C++11, not that it's a big deal or anything.

 

EDIT:  I got curious after typing this, so I went and found this little gem:

 

http://cpprocks.com/c1114-compiler-and-library-shootout/

 

Apparently, clang and gcc now completely support C++11.  I don't think you're likely to have access to ICC, so the above is basically gospel now.



#3 thade   Members   -  Reputation: 1652

Like
1Likes
Like

Posted 29 April 2014 - 09:57 AM

My understanding is that std::thread is windowthreads in Windows and pthreads in most other places...so you should be alright using it. :) If you were explicitly using one or the other, you'd certainly run into trouble.


I was previously serratemplar; a name I forfeited to share a name with an angry rank-bearing monkey.

http://thadeshammer.wordpress.com/


#4 Jan2go   Members   -  Reputation: 698

Like
2Likes
Like

Posted 29 April 2014 - 10:03 AM

I'm using std::thread on Windows with Visual Studio 2012, MinGW and on Ubuntu with gcc. On gcc and MinGW you have to add the "-std=c++11" flag to make the C++11 standard available.



#5 cyberspace009   Members   -  Reputation: 179

Like
0Likes
Like

Posted 29 April 2014 - 10:44 AM

Right now, I think the general rule of thumb with C++11 is "If it works in VS2012, it works anywhere".  Both clang and gcc (the other two major C++ compilers) are pretty much strictly ahead of VS in C++11.

 

However, I believe you need the correct compiler switches on the other platforms for C++11, not that it's a big deal or anything.

 

EDIT:  I got curious after typing this, so I went and found this little gem:

 

http://cpprocks.com/c1114-compiler-and-library-shootout/

 

Apparently, clang and gcc now completely support C++11.  I don't think you're likely to have access to ICC, so the above is basically gospel now.

 

Thanks. I'll keep working on my game with no worries now :).






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS