• Advertisement
Sign in to follow this  

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

This topic is 1363 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.  

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 :).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement