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

Started by
3 comments, last by cyberspace009 9 years, 11 months ago

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.

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.

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'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.

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

This topic is closed to new replies.

Advertisement