# Using C++11 for cross-platform Game Engine Development

Note: This is not a 'give your opinion' question about C++03 and C++11.

Our game engine, written in C++03, is designed to be compiled on Windows, OSX and iOS. Linux support is planned for the (very) near future. Our experience is limited when it comes to consoles, which is why I am asking this question.

Currently, we are debating whether switching to C++11 and using non-compatible features of the C++11 standard could pose a problem in the near future when we need to port our engine to any of the current gen consoles (perhaps the compilers supported by some console(s) do not support C++11 yet? We don't know...).

So, game developers who have experience across multiple platforms and consoles, do you think we should stick to C++03 until the new generation of consoles arrive and most everybody has switched to C++11 standard (have they already?). Or are most consoles using/support compilers (VC++, GCC or variants?) that are already supporting C++11 features?

• My knowledge is somewhat out of date so I won't post this as an answer, but my past experience of console compilers is that you're lucky if they match the old standard, never mind a new one. – Kylotan Nov 27 '12 at 21:59
• Which features and why are they so important that you consider using a standard that is not fully implemented even on the most popular development platforms? – snake5 Nov 27 '12 at 22:00
• @snake5: auto, lambda's, template alias, c-tor delegation. These features will not only make our code more readable/maintable but imo increase productivity. Just the auto keyword is one of the things I miss a lot when I switch from C++11 to C++03. Other features such as variadic templates, although very powerful and can definitely improve code, we can do without (and are not implemented so far by VC++ compiler). – Samaursa Nov 27 '12 at 23:47
• Adding to what Kylotan commented, i fully agree with his opinion, and even add a particular example in my experience. If you re going to extend that engine to the android platform, which can be done using C++, you will have a bad time as the C++ features are incomplete in the NDK. You won't be able to use the new standard and even some things in the previous will be faulty. – Grimshaw Nov 28 '12 at 0:00
• @DevilWithin, I've been using quite a few C++11 features in the Android NDK without any problems. – notlesh Nov 28 '12 at 1:04

If you rely on your code in order to pay for food and shelter, and you need to support cross-platform on unknown future platforms (or reasonably might need to support cross-platform in the future), then designing your code to rely on a bunch of unknown compiler writers' correct adherence to bleeding edge language standards is dangerous (and I would argue, irresponsible). It's dangerous for you, and therefore also dangerous for your dependents.

If you're willing to take that sort of risk for the sake of auto, then by all means, go for it. But I'm not going to advise you to do it.

Because in my experience, going cross-platform, particularly on consoles, is best accomplished by aiming for the lowest common denominator which you can be certain will work virtually everywhere, not by relying on all the latest whiz-bang language features. If someday you need to port to a platform which doesn't support them, you wind up having to rewrite your systems from scratch. Can you afford to pay wages/rent while that happens?

• +1 for this (and the rest of the post, but this): "rely[ing] on a bunch of unknown compiler writers' correct adherence to bleeding edge language standards is dangerous". Experimenting with the latest toys is always fun, relying on them not so much. – NoobsArePeople2 Nov 28 '12 at 4:32
• I'm always really anxious about giving these "be cautious" answers, particularly when they clearly aren't what the original poster wants to hear. But I've seen big compiler bugs on consoles too many times in my career for me to feel comfortable jumping onto new language standards in a cross-platform project. Needing to rewrite your code to get around issues in a compiler is never any fun, particularly when you're under a deadline. – Trevor Powell Nov 28 '12 at 5:21
• I'm not going to downvote this but the new C++ standard is so much more than syntactic sugar such as the auto keyword. – vdaras Jul 2 '13 at 13:38
• @TrevorPowell, you said that the risk that he would take was for the sake of auto keyword, when there are much more important and fundamental features in the new C++ standard. Some of them, like rvalue references, would be have to be taken into important consideration when thinking about the risk. – vdaras Jul 4 '13 at 14:17
• @TrevorPowell that's why I said that the post isn't worth downvoting despite any arguments I have about it. I believe that this is a good post, I just wanted to clarify that the new C++ standard has some very important features and considering using it wouldn't just be about a minor thing like auto. – vdaras Jul 5 '13 at 9:39

If your willing to do a bit more work, you could look into refractoring solutions. clang has some interesting stuff happening in that area currently. It should be possible to use the auto keyword, run it through the refactorer which will find all uses of it, resolve them for you and output the code then compile it with whatever you want.

But that means less time to work on your game.

There is also the potential for some extra features, for example reflection. You could create a class and automatically generate a list of all the properties to inspect at runtime. Could be very useful for scripting, producing game editors and so on. EDIT: Check out clreflect.

http://cppnow.org/session/refactoring-c-with-clang/

• This reminds me of something like python's 2to3 but in reverse and a lot more awesome but probably more difficult to use. Man, how much better can auto get? – Steven Lu Jun 30 '13 at 6:17