Download

Does iOS building support new features of C++ 11?

Hi guys,

I’m a noob of UE4. I’d like to know if iOS building supports new features of C++ 11? It always failed:( Thank you!

Hi pianpian,

Yes. We use Apple’s Clang/LLVM toolchain to compile for iOS and it supports C++11 pretty fully. However, we are cautious with C++11 features that we use in the engine, as we support a wide variety of platforms including one that still requires a VS 2012 toolchain, so we only allow internal development to use a subset of C++11 features. Currently this subset includes auto, range-based for loops, nullptr, etc…

Cheers,
Michael Noland

Hi Michael,

Thank you for your reply. Does UE4 supports C++ 11 features: shared_ptr, unique_ptr and std::function for iOS? I can build the project for Window and Mac, but not for iOS.

Also, can I use mac to compile Unreal Build Tool? Because I want to change some compile configurations of GetCompileArguments_CPP in IOSToolChain.cs for iOS.

Thank you!

Regards,

Hi pianpian, not sure if this helps, but I found this: http://stackoverflow.com/questions/12819886/no-type-named-shared-ptr-in-namespace-std

We don’t really use std libraries in UE4 ourselves and only rely on the language features and our own container classes (TSharedPtr etc).

UnrealBuildTool can be compiled on the Mac with Mono. There’s a special mono project for UBT under Engine/Source/Programs/UnrealBuildTool/UnrealBuildTool_Mono.csproj

Hi Robert, sorry for the late reply. Thank you for your help. The original IOSToolChain.cs does not include C++ 11 lib. It seems useless to just configure build settings in xcode. We need to modify IOSToolChain.cs such as add ‘Result += " -std=c++11"; Result += " -stdlib=libc++"’ and use Mono to compile UnrealBuildTool. In this way we can use C++ 11 features for iOS version.

Thanks pianpian, we will make those changes on our end too.

Currently, in UE v4.5.0, IOSToolChain.cs still seems to not enable C++11. Any hope to have it fixed soon?

Will be in 4.6 as it was just updated this week.

-Pete

Thanks Pete!

It worth noting, for anyone else who finds this, that simply adding -std=c++11 when the immediately following line is -stdlib=libstdc++ doesn’t achieve much, because libstdc++ does not implement C++11 and uses the wrong set of headers. You’ll have to hack the builder to make C++11 features work in IOS builds.

@shadowmint, do you have more details on what was involved to get c++11’s stdlib working with ios builds?